Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read a file line when it contains * 2

Status
Not open for further replies.

Yarka

Technical User
Jan 14, 2007
192
ES
Hi.
My script is such as:
$ ./a.sh input.txt
where a.sh has:

#!/bin/sh
out=/root/probe/out.txt
cat $1 |while read LINE
do
echo $LINE >> $out
done

and input.txt has:
111 666 888 000 999 * 66
3 3 999 * 8 8

each column is separated with tabulation.

The problem is when I execute my script. The output of out.txt is:

111 666 888 000 999 a.sh input.txt 66
3 3 999 a.sh input.txt out.txt 8 8

i.e., where there is * (in the input.txt file) puts the files of the current folder (/root/probe/).
How can I make so that it lists to me the line so as it has input.txt, reading the file line to line and without be able to change input.txt file?

Thanks.
 
and what about this ?
#!/bin/sh
out=/root/probe/out.txt
while read LINE
do
echo "$LINE"
done < $1 >> $out

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Inside the while I need to have lines one to one. This is because of them I must extract values and to make a series of operations.


Thanks.
 
What do you want to do ?
I've replied your OP and don't see where I'm wrong ...
 
Hi

With or without the UUOC, the important for you are the double quotes ( " ) :
Code:
echo [red]"[/red]$LINE[red]"[/red]
But I suggest to listen to PHV regarding the redirecting too.

Feherke.
 
Particularly, pay attention to the input/output redirection after the done keyword.

HTH,

p5wizard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top