![]() |
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 |
| question to build a shell script | vishalpatel03 | Shell Programming and Scripting | 5 | 12-12-2007 12:45 PM |
| Build script for all shells | vino | Shell Programming and Scripting | 9 | 04-14-2005 01:25 AM |
| Script Build | mewalter | Shell Programming and Scripting | 3 | 07-09-2002 06:30 PM |
| I want to build a script | mewalter | Shell Programming and Scripting | 2 | 07-01-2002 07:32 PM |
| Build my box... | KyPeN | UNIX for Dummies Questions & Answers | 7 | 03-02-2002 10:31 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
I want to build a script
I have this script
sed -e '$q' -e 's/I/D/g' <inputfile> outfile which replaces I by D... I have to run this script in 90 files which their filename starts with CD*. I want to call all these files and execute this command once. Or schedule it to be executed at 1600hrs every day. I want to output to the same i.e I'm modifying these file so input file has to have the same file as the output. thanx forwarded |
|
||||
|
you can do this
#!bin/sh for file in `ls CD*` do sed -e 's/I/D/g' < $file > $file.out mv $file.out $file done If you want to run it at a specific time, use the cron command there have been plenty of posts on this site about it already. |
|
||||
|
Just curious what your $q is doing? From the syntax it looks like another sed command....just something I learnt the other day...
Quote:
|
|
|||||
|
He actually doesn't want to change the last line. 'q' is a command that makes sed quit. '$' addresses the last line. So when the last line is encountered, sed exits so that second command never runs. See this thread.
|
|
||||
|
perl -pi -e
The -i option in Perl will edit the specified file "in place", so you don't have to mess with moving files around.
% echo "eat food" >> test.txt % echo "eat more food" >> test2.txt % perl -pi -e 's/food/pie/g' * % cat test.txt eat pie % cat test2.txt eat more pie -i takes an optional argument. If specified, a backup will be saved with the argument as the file's extension. % perl -pi'.bak' -e 's/pie/chicken/g' * % ls test.txt test.txt.bak test2.txt test2.txt.bak % cat test.txt eat chicken % cat test.txt.bak eat pie |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|