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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Echoing variables

Status
Not open for further replies.

rakeshs859

Technical User
Joined
Aug 24, 2003
Messages
8
Location
US
Hello, I'm reading a file that has a string with spaces such as a sentence. If I want to read the string and echo it out, it only shows me the 1st word. How can I get echo to print out the entire string. I've tried the \n and \c arguments and they don't help.

Any help would be appreciated.

Thanks.

Rakeshs859
 


Did you try echo "$STRING"?


----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
How are you reading your file ?
Try something like this:
Code:
while read buf; do
  echo "$buf"
done </path/to/yourfile

Hope This Help
PH.
 
Hello,

Let's say that my string that is read from the file such as the following code:

for line in `cat list.txt` ; do
{
echo $line
}
done

It only echos the first word of a line that contains spaces such as a sentence. I want to echo the entire line.

Any help would be appreciated.
 
Thank you PHV,

That did the trick!

Cheers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top