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

grep command

Status
Not open for further replies.

alhassani54

Programmer
Aug 1, 2002
27
GB
Hi

I have a text UNIX file (file1), the file contains one line and the line contains spaces as.
Abc 1234567 abcdef log 123456789,456789

If I do grep from the shell I will get the line as in the file.

$grep log file1
$Abc 1234567 abcdef log 123456789,456789

But if I assign the grep to a variable the spaces will be removed as.

$var=$(grep log file1)
$print $var

$ Abc 1234567 abcdef log 123456789,456789

Is it possible to print the line as in the file?
Any help will be appreciated

Thank you
 
just enclose your variable in double quotes before printing it out.

Code:
$var=$(grep log file1)
$print [COLOR=#ff0000]"[/color]$var[COLOR=#ff0000]"[/color]

will print $var as found in the file.
IE
Abc 1234567 abcdef log 123456789,456789
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top