The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Find files in directory coldstarhk Shell Programming and Scripting 3 09-29-2008 03:03 AM
Shell:Find a word in files in a directory and subdirectories yeclota Shell Programming and Scripting 4 08-29-2008 06:05 AM
find a word in a file, and change a word beneath it ?? vikas027 Shell Programming and Scripting 2 02-13-2008 04:23 PM
find files and copy into a directory balireddy_77 Shell Programming and Scripting 4 04-27-2007 04:38 AM
search for certain word in a files from directory legato UNIX for Dummies Questions & Answers 1 10-31-2006 06:35 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-30-2008
shikhakaul shikhakaul is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 11
Exclamation How to find a word in a all the files in a Directory??

I want to find a specific word present in all the files ina directory....Please tell me the command to be used??

Thanks
  #2 (permalink)  
Old 09-30-2008
nua7 nua7 is offline
Registered User
  
 

Join Date: Mar 2008
Location: /bin/sh
Posts: 353
Code:
grep <word to be searched> <path of the directory or *(if running from the directory)>
  #3 (permalink)  
Old 09-30-2008
harshakirans harshakirans is offline
Registered User
  
 

Join Date: Sep 2008
Location: Bangalore, India
Posts: 5
Hi,

Try this out.
[code]
find . -type f -exec grep -i searchstring \{\} filename;
[\code]
  #4 (permalink)  
Old 10-03-2008
shikhakaul shikhakaul is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 11
Exclamation Thank you and one more question

print "count,pub,prodline,group,sector,date,source" > $fname

cat sp_log.summary.$firstday-$lastday.ProdlineSector | sed "s/^ *//g;s/ *$//g" >sp_log.summary.$firstday-$lastday

cat sp_log.summary.$firstday-$lastday | sed "s/$/ $lastyy-$lastmm cache/;s/ /,/g" >> $fname

cat $fname | sed "s/NULL//g" >$fname.new


THIS is the part of a shell script which creates a .CSV file.

Now for the data under pub field, i want to inset a ' in front of the data getting inserted.

Can someone please help??
  #5 (permalink)  
Old 10-03-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Replace the last command with something like

Code:
sed -e 's/NULL//g' -e "2,\$s/,/,'/" $fname >$fname.new
This adds a single quote immediately after the first comma, except on the first line. Take out the 2,\$ prefix if you want it on the first line, too.

All the other occurrences of cat are Useless, too; sed is perfectly capable of reading from a named file all by itself.
  #6 (permalink)  
Old 10-03-2008
shikhakaul shikhakaul is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 11
Query

Thank you, i will check it out...

1 more query i had, in the first question, the grep method worked, Thanks

But if i want to get the results page vise what is the command??
sibce it scrolls down and i am nto able to note anything

Thanks All for your help!!!
  #7 (permalink)  
Old 10-04-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Code:
commandwithlotsofoutput | less
... or "more" if you don't have less. (Or "pg" if you have neither, but then you probably don't have a web browser either.)
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:08 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0