redirecting a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting redirecting a file
# 1  
Old 07-12-2007
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  
Old 07-12-2007
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  
Old 07-12-2007
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  
Old 07-12-2007
Quote:
Originally Posted by wip_vasikaran
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Redirecting output to file

Hi, I have created script which redirect the output to file.I am able to get the output in file but not in the format. Output :Content of the log which have 10 -15 lines. Actal :Line1 ..Line 2Line3 Line4 Line 5 Expected:Line1 Line 2 Line3 Please... (7 Replies)
Discussion started by: karthik771
7 Replies

2. Shell Programming and Scripting

Redirecting output to file through cron

Hi Does anyone have any suggestions for capturing the output into a file when i run it through cron? I have file called "quick.1" which contains two simple commands to be executed on the target host. And i have second file called "quick.2" which contains the wrapper script to ssh to the target... (1 Reply)
Discussion started by: chandika_diran
1 Replies

3. Shell Programming and Scripting

redirecting with file descriptor

hello, Someone can help me with redirectors? I am writing this script in bash enviroment on Fedora: exec 4<> /dev/tcp/10.10.11.30/5000 #open socket in input/output strings<&4 >file.txt & I send file descriptor 4 to string command to purge data stream from special char while come from... (3 Replies)
Discussion started by: rattoeur
3 Replies

4. Shell Programming and Scripting

Redirecting STDERR to file and screen, STDOUT only to file

I have to redirect STDERR messages both to screen and also capture the same in a file but STDOUT only to the same file. I have searched in this formum for a solution, but something like srcipt 3>&1 >&2 2>&3 3>&- | tee errs doesn't work for me... Has anyone an idea??? (18 Replies)
Discussion started by: thuranga
18 Replies

5. Shell Programming and Scripting

extracting line numbers from a file and redirecting them to another file

i have applied the following command on a file named unix.txt that contains the string "linux from the text" grep -n -i -w "linux from the text" unix.txt and the result is 5:Today's Linux from the text systems are split into various branches, developed over time by AT&T as well as various... (5 Replies)
Discussion started by: arindamlive
5 Replies

6. Shell Programming and Scripting

Reading UNIX commands from file and redirecting output to a file

Hi All I have written the following script: #!/bin/ksh while read cmdline do echo `$cmdline` pid="$cmdline" done<commands.txt =========== commands.txt contains: ps -ef | grep abc | grep xyz |awk '{print $2}; My objective is to store the o/p of the command in a variable and do... (8 Replies)
Discussion started by: rahulparo
8 Replies

7. Shell Programming and Scripting

redirecting the terminal to file

Hi, I want to save the whole Output of the terminal in a file. I dont want to redirect a single command to a file (ls -l > test.txt), I want to redirect the whole last 40 lines into a file. Maybe i can read out the terminal while working with it, but i cant find a way to save the whole... (2 Replies)
Discussion started by: niratschi
2 Replies

8. Shell Programming and Scripting

Redirecting output to file

Hi, Below is the whole string which is to be redirected to the new file. su - oracle -c "exp $user/$pass file=/oracle/oradata/backup/exp_trn_tables_`date +%d_%b_20%y_%H_%M_%S`.dmp log=/oracle/oradata/backup/exp_trn_tables_`date +%d_%b_20%y_%H_%M_%S`.log tables=table1,table2 statistics=none" ... (3 Replies)
Discussion started by: milink
3 Replies

9. Shell Programming and Scripting

matching file and redirecting

Hi all I have two file a.txt and b.txt and i want to compare their first coloum and print the o/p to the third file c.txt comparing should be in such a way that if matching first coloum is not found in any of the file then it should print No row like here AAA is present in both file so o/p... (6 Replies)
Discussion started by: aaysa123
6 Replies

10. UNIX for Advanced & Expert Users

Redirecting to Error File

Hi- I want to redirect the output of the echo to the standard error file. We require this because, when we try to scp a file from a source server to a target server we get an error code 1. Later we found that it was due to the .cshrc file which outputs on stdout which is making the scp to fail.... (1 Reply)
Discussion started by: lorcan
1 Replies
Login or Register to Ask a Question