Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums

Go Back   Code Forums > Systems > Linux / BSD / OS X

Reply
 
LinkBack Thread Tools Display Modes
Old 04-25-2007, 12:54 AM   #1 (permalink)
rudranee
Recruit
 
Join Date: Apr 2007
Posts: 1
rudranee is on a distinguished road
Question Writing to a file through shell

hi,
I new to shell scripting but have experience with C,C++ and Java for quite some time.
I want to write a shell script where i'm extracting some values from i/p file and writing these to another file.
For reading i'm using

FILE=$1
while read line
do
#some action
done < $FILE

but i'm not able to find how to write to a file
Sorry if asking very bsic question but i have googled and even read some online scripting books but nothing looks satisfactory.

Thanx.
rudranee is offline   Reply With Quote
Old 04-25-2007, 01:59 AM   #2 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,166
Belisarius is on a distinguished road
If you're using bash, I've always found the Advanced Bash-Scripting Guide.

Basically, to write out a file, you need to "echo" out values. That is,
Code:
echo ${FOO} >> ${FILE}
In case you don't know, '>>' appends the output to the specified file, whereas '>' over-writes what's currently there.
__________________
GitS
Belisarius is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
File handling in Shell Script ashok rajagopal Linux / BSD / OS X 2 01-17-2006 01:26 PM
file types: reading and writing pre_wreck Standard C, C++ 2 09-26-2005 05:49 AM
having trouble with writing to file philthee Java 2 11-09-2004 05:32 AM


All times are GMT -8. The time now is 03:11 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting