sed to read


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers sed to read
# 8  
Old 12-01-2009
Another option, without sed:
Code:
{ read ; read var1 var2 ;} < file.dat
echo $var1 $var2

# 9  
Old 12-01-2009
Move the closing ! to the first character of the line:

Code:
    read var1 var2 junk << !
    $(sed -n '2p' fit_par.dat)
!


Output:
file1 2 0

When all is said and done, if it's always line two you want, the "read; read..." option is nice and simple.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed read X lines after match

I want to do something like sed -n '/PATTERN/,+10p' and get the ten lines following PATTERN. However, this throws an "expected context address" with the sed that comes with OSX Lion. If that + is a GNUism, can I do this, or do I have to find another tool? (2 Replies)
Discussion started by: jnojr
2 Replies

2. Shell Programming and Scripting

Having sed to read lines of a file with the use of a variable..Possible?

This i will print the second line of a file sed -n '2p' test2 The use of a variable is impossible here. a=1 while ; do line=`sed -n '$a p' test2` # do some things here with the line variable a=`expr $a + 1` done But the uotput of sed command is 'p'..... What can i do to use a variable... (2 Replies)
Discussion started by: hakermania
2 Replies

3. Shell Programming and Scripting

read file-print lines in sed

Hello! Im trying to read file contents. Then, print out every line that has "/bens/here" in the file that was read. cat /my/file.now | sed '/bens/here/p' I keep getting the error asking if I need to predeclare sed? What does predeclaring sed mean? Thanks! Ben (2 Replies)
Discussion started by: bigben1220
2 Replies

4. Shell Programming and Scripting

sed search and read the RHS information: Linux 2.6.9-89

Hi, I have a config_file.cfg with the content: FILE_ID_1=1 FILE_FTP_ID_1=<FTP_SERVER1.COM> .... FILE_ID_2=2 FILE_FTP_ID_2=<FTP_SERVER2.COM> .... so on for 28 times. As you might have guessed it; the script I have to write is to read this config file and get the FTP server... (3 Replies)
Discussion started by: dips_ag
3 Replies

5. Shell Programming and Scripting

Read a file content with awk and sed

Hello , I have huge file with below content. I need to read the numeric values with in the paranthesis after = sign. Please help me with awk and sed script for it. 11.10.2009 04:02:47 Customer login not found: identifier=(0748502889) prefix=(TEL) serviceCode=(). 11.10.2009 04:03:12... (13 Replies)
Discussion started by: rmv
13 Replies

6. Shell Programming and Scripting

need sed command to read a path and set to variable

I have a variable called PATH that contains a path example: /Users/rtipton/Desktop/testusers/test I need a sed command to set a variable called USER to the last directory name in that path PATH="/Users/rtipton/Desktop/testusers/test" and from that PATH i need USER to = test I know sed... (4 Replies)
Discussion started by: tret
4 Replies

7. Shell Programming and Scripting

SED command for read and write to different files

Hi I need some help on SED command I am writing a shell script which does the following: 1. Read one line at a time from a file abc.txt which has millions of lines 2. Prefix each line read with some text " 3. Post fix each line read with a quote " 4. Write the new modified... (11 Replies)
Discussion started by: gaurav_1711
11 Replies

8. Shell Programming and Scripting

Using Sed to read one line only

I have a bash script which produces the desired output (mostly). tempTxt=`sed -n '79,/^$/p' <sourceFile.txt | cut -c 13-19` What this produces is the text from the 79th line of the source file and cuts the text to the 13th through the 19th chars. Then the script does the same thing... (4 Replies)
Discussion started by: roninuta
4 Replies

9. Shell Programming and Scripting

SED and Read Help Needed

Not sure why my sed script is not working..need extra eyes..Any help would be aprreciated. I want to add this line into the 1rst line of the $EJECT FILE sed '/">>>>>>>>>>>>> TAPES TO BE EJECTED /a\<<<<<<<<<<<<<<<<<"'> $EJECT This is the error message I get: + sed /">>>>>>>>>>>>> TAPES TO... (1 Reply)
Discussion started by: gzs553
1 Replies

10. Shell Programming and Scripting

sed to read and write to very same file

This is likely to be a dumb one. How can I use sed to substitute string occurances having it read from an input file and write to this very same file ? I have a file with lots of occurances of '2006', I want to change it to '2007', but I'd like these changes to be saved on the input file. ... (5 Replies)
Discussion started by: 435 Gavea
5 Replies
Login or Register to Ask a Question