who to deal with whole line in shell scripting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting who to deal with whole line in shell scripting
# 1  
Old 08-02-2006
who to deal with whole line in shell scripting

I have a problem in my HP Unix system , it is briefly :
I have two files : Myfile and Script.sh :
Myfile contain this lines :
Code:
String1         string2         string3        string5 
String1         string2         string3        string5 
String1         string2         string3        string5 
String1         string2         string3        string5 
String1         string2         string3        string5 
String1         string2         string3        string5 
String1         string2         string3        string5 
String1         string2         string3        string5


And Script.sh files has :
Code:
for x in $(<Myfile)
do
echo $x
done

the output will like this :
Code:
string1
string2
string3 
string1
string2
string3 
string1
string2
string3 
string1
string2
string3

it means this script deal with word as $x I want deal with whole the line as $x , I want the output like this :
Code:
String1         string2         string3        string5 
String1         string2         string3        string5 
String1         string2         string3        string5 
String1         string2         string3        string5 
String1         string2         string3        string5 
String1         string2         string3        string5 
String1         string2         string3        string5 
String1         string2         string3        string5

# 2  
Old 08-02-2006
how abt this ?

Code:
while read line
do
echo "$line"
done < Myfile

# 3  
Old 08-02-2006
perfect ......
Many many thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Scripting , need to search and print a line that contains a specific pattern

Take example of below file. abc.txt nas1:/abc/test/test1 /test nas1:/abc/test/test1/test2 /test/abc nas1:/abc/test/ Now i have a variable that contains "nas1:/abc/test/test1" value , so i need to search the above file for this variable and print only this line. ... (14 Replies)
Discussion started by: mohit_vardhani
14 Replies

2. Shell Programming and Scripting

Need one line scripting on Unix shell..help!!

Hi Experts, I need one line script for the below requirement. First it should check if a directory with todays date exist, and if not create it and move the PDF file to that directory. thanks in advance!!! (2 Replies)
Discussion started by: eeegopikannan
2 Replies

3. Shell Programming and Scripting

Shell Scripting:Fetching content from each line with respect to pattern.

one.txt ONS.820.log:V 20Oct2010:GP ^ ^ ONS.123.log:V 21Oct2010:GP ^ ^ ONS.820.log:V 30Oct2010:GP ^ ^ want to make new file from existing one with addition. 20Oct2010 User KV001 has name tk003 with buffer- 338-1 21Oct2010 User KV003 has name tk002 with buffer- 338-2 30Oct2010 User KV002... (5 Replies)
Discussion started by: saluja.deepak
5 Replies

4. Shell Programming and Scripting

sed/shell scripting - add line if needed and not allready there

I am writing a shell script that checks all .c files to see if they use fprintf or printf. If a file does, then the line #include <stdio.h> is added to the top of the file, unless it's already there. This is what I've got: #!/bin/sh egrep -l f?printf *.c | while read file; do sed -i '1i\... (2 Replies)
Discussion started by: computethis
2 Replies

5. Shell Programming and Scripting

How to compare a command line parameter with -- in shell scripting

Hi, I need to check if a parameter provided at the command line is equal to --.How can i do that ? Please help me. Thanks and Regards, Padmini (4 Replies)
Discussion started by: padmisri
4 Replies

6. Shell Programming and Scripting

add a line at the end of a file using shell scripting

Hi All , I am new to shell scripting. i have a shell script(which is executed as a super user) , i want to it to do one more job for me. ie mounting a directory over other using lofs . i have done it manually using 1) using mount command mount -F lofs /export/home/dju /dju 2)... (4 Replies)
Discussion started by: meet123321
4 Replies

7. Shell Programming and Scripting

Delete a portion of a line using shell scripting

Hi all, I am new to awk programs.I have a file like this 1234567@2345||adcbdefhij: asgdfdasdfhhfd-asdfasd-dsfasdf |0.678|0.0|0.213 1234567@2345||adcbdefhij: ashhfd-asdfasd-dsfasdf |0.129|0.0|0.411 1234567@2345||adcbdefhij: asd-aasd-dasdf |0.223|0.0|0.276 I want to delete the text which... (3 Replies)
Discussion started by: Loy81
3 Replies

8. Shell Programming and Scripting

Need help in splitting a line into fields in shell scripting

I have a line of more than 3000 bytes which will contain & as fields separator..I am using following awk command ..Its working but its not accepting the line more than 3000 bytes...Anyother alternate solution even in othe shell command also fine... awk -F '&' '{for( i=1; i<=NF; i++ ) print $i}'... (2 Replies)
Discussion started by: punithavel
2 Replies

9. Shell Programming and Scripting

How do i iterate thru each line of a file in shell scripting?

Hi All, I need to execute some commands on each line of a file. How do i iterate thru each line of a file? In detail: First i will have to go to the first line of the file and execute a series of commands on it and then take the second line of the file, execute a series of steps and so... (2 Replies)
Discussion started by: Ravi Varma
2 Replies

10. Shell Programming and Scripting

End of Line in Shell Scripting

I have a file containing records seperated by delimiter '|'.A record is contained on 2 or 3 lines. Now I need a shell script which could write all records with in two '|' character in one line.....for example..... |R1........................R1 R1..........................R1... (2 Replies)
Discussion started by: 33junaid
2 Replies
Login or Register to Ask a Question