If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > what are these options

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-12-04, 18:58
saccskiz saccskiz is offline
Registered User
 
Join Date: Feb 2004
Posts: 143
what are these options

Hi,
A question -

find . -name '*.sh' | xargs perl -p -i'_save' -e 's+rick+brick+g'

In this command, I know that it replaces all occurances of rick in the .sh files and changes it to brick. And also makes a copy in the _save file.


Now what does xargs, perl , -p, -i and -e options indicate?

Thanks
Reply With Quote
  #2 (permalink)  
Old 04-13-04, 06:04
aigles aigles is offline
Registered User
 
Join Date: Jan 2004
Location: Bordeaux, France
Posts: 319
man find
man xargs
man perl

find . -name '*.sh'
find all files named '*.sh' in the current directory and sub-sirectories, and print filenames to stdout

xargs perl ...
xargs reads filenames (arguments) from the standard input and executes the command 'perl' one or more times with any initial-arguments followed by arguments read from standard input.
For example, if there are two file 'start.sh' ans 'stop.sh', wargs build and executes the following command :
perl perl -p -i'_save' -e 's+rick+brick+g' start.sh stop.sh

perl -p -i'_save' -e 's+rick+brick+g'
Execute perl with the options :
-p : causes Perl to proceed input files line by line, executing the program (-e '...') for each line
-i'save_' : input files are saved with name *.sh_save, output files are named *.sh
-e 's+rick+brick+g' : specify a line of program to execute. Substitutute all occurence of 'rick' by 'brick' in the input file(s).
__________________
Jean-Pierre.
Reply With Quote
  #3 (permalink)  
Old 04-13-04, 09:54
saccskiz saccskiz is offline
Registered User
 
Join Date: Feb 2004
Posts: 143
Thanks a lot
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On