The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 02-07-2008
Registered User
 

Join Date: Feb 2008
Posts: 15
using sed

hi.. i am trying to find files containing a certain text. the following is my code


Code:
find . -exec grep -l  "sometexttobefound" '{}' \; -print | uniq | sed 's/[\r\n]/,/g' `
the result of the find might return multiple filepaths, but they are printed on different lines. my aim is to print them on the same line separated by comma. i used "sed" for this purpose as shown in code, but it doesn seem to be working.

infact, not quite sure if my regular exp is right for carriage return. ????
Reply With Quote
Forum Sponsor
  #2  
Old 02-07-2008
Registered User
 

Join Date: Nov 2007
Location: Belgium & France
Posts: 70
Code:
var=$(find . -exec grep -l  "sometexttobefound" '{}' \;)
var=$(echo $var | sed 's/ /,/g')
echo $var
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 06:56 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0