The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
redirecting variable content to a file! lloowen Shell Programming and Scripting 2 05-24-2008 05:30 PM
Redirecting <talk> output to a file cej Shell Programming and Scripting 4 01-21-2008 03:26 PM
Redirecting to Error File lorcan UNIX for Advanced & Expert Users 1 10-12-2007 02:07 AM
redirecting serial inputs to a file? guilartec Shell Programming and Scripting 4 02-27-2006 11:30 PM
redirecting output to file in network anent UNIX for Advanced & Expert Users 1 11-16-2001 06:51 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-12-2007
wip_vasikaran wip_vasikaran is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 14
redirecting a file

Hi,

I have a normal txt file which contains say 5 lines. in that i need to change few of the the parameters dynamically.

for eg..

line 1..contains account
line 2 contains date
line 3 contains user
..
..
..

i will be taking the input using read command and store it in variables account,date and user variables..

but now.. how will i capture that in the txt file..

Pls help.

Thanks
  #2 (permalink)  
Old 07-12-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398

Code:
read account
read date
sed -e "1 s/^.*$/$account/" -e "2 s/^.*$/$date/"  file > temp
mv temp file

Similarly add commands in sed to change other lines.
  #3 (permalink)  
Old 07-12-2007
wip_vasikaran wip_vasikaran is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 14
redirecting

sorry .. i didnt mention one thing..

How to read from the file.. or how to store the contents of a file using script.

i mean.. I have a file called total.txt and i want to take some data from the file to do some manipulations..

is this the right command..

a << total.txt
  #4 (permalink)  
Old 07-12-2007
anbu23 anbu23 is offline Forum Advisor  
Registered User
  
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,398
Quote:
Originally Posted by wip_vasikaran View Post
sorry .. i didnt mention one thing..

How to read from the file.. or how to store the contents of a file using script.

i mean.. I have a file called total.txt and i want to take some data from the file to do some manipulations..

is this the right command..

a << total.txt
If you the know line numbers of the required lines then try this

Code:
a=$( sed -n "3,10 p" total.txt )

Retrieve text from third to tenth line.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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




All times are GMT -4. The time now is 04:29 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0