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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
xlC compilation error when dealing with operator overloading luop0812 AIX 1 04-09-2008 05:09 PM
perl: When dealing with files that do not exist joeyg Shell Programming and Scripting 2 02-20-2008 05:09 PM
Help in dealing with arra jojan Shell Programming and Scripting 5 08-28-2007 03:14 PM
Problem starting a script from a 'main'-script Rakker UNIX for Dummies Questions & Answers 3 06-28-2005 09:12 AM
how to change sh to tsch UNIX simt UNIX for Dummies Questions & Answers 2 12-19-2003 05:03 PM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 05-02-2007
csnewbie84 csnewbie84 is offline
Registered User
  
 

Join Date: May 2007
Posts: 12
tsch script problem (dealing with sed)

This is my first post so I hope I didn't cross any violations


I have this script


Code:
#!/bin/tcsh
set pattern1=$1
shift
set pattern2=$1
shift foreach file ($*)
set data=`echo $file | sed s/$pattern1\$/$pattern2/g`
$data > $file
end

My parameters are
1. the string to be replaced
2. the string with which to replace it
3. the name of the file in which to make the substitution

I want to produce a new script that will apply a substitution to any number of files given on the command line like
/tmp/subst cat dog File1.txt File2.txt File3.txt

but I know I either missing something or I need to modify it but don't know what cause the script will not work for me at all.

Thanks for any assistance.
 

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:40 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