![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Shell script getting input from output | aspect_p | Shell Programming and Scripting | 1 | 03-11-2008 07:37 AM |
| Unix Shell Script with output to CSV File | heather.morton@ | UNIX for Advanced & Expert Users | 1 | 01-28-2008 01:18 PM |
| redirecting SQL output from within a shell script | soliberus | Shell Programming and Scripting | 2 | 11-23-2007 08:29 AM |
| reading command output from shell script | sri b | Shell Programming and Scripting | 4 | 11-16-2006 12:52 AM |
| Capturing shell script command output | designflaw | Shell Programming and Scripting | 2 | 03-01-2006 04:24 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
I'm trying to automate numerous grep searches via shell scripting. However, the output of echo is ONE line whereas grepping from the command line would give line breaks as seen in the file. For example:
test.txt: 12345 - hi 12345 - how 54321 - are 12345 - you grep output would be: >grep "12345" test.txt 12345 - hi 12345 - how 12345 - you using echo within my script to display the grep: >echo `grep "12345" test.txt` 12345 - hi 12345 - how 12345 - you Is there anyway to fix that last output to match the previous, i.e. with line breaks rather than all on one line? Or is there some other method? Thanks! |
|
||||
|
to get the results you're looking for wrap quotes around it:
Code:
echo "`grep "12345" test`" Last edited by DeCoTwc; 09-19-2008 at 10:33 PM.. Reason: fixed code tag |
|
||||
|
You know what, for some reason I was thinking in terms of him echoing a variable that held the results of an earlier grep...so yeah, echoing it doesn't seem to make a whole lot of sense I suppose.
|
![]() |
| Bookmarks |
| Tags |
| echo, grep |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|