![]() |
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 |
| Search, replace string in file1 with string from (lookup table) file2? | gstuart | Shell Programming and Scripting | 9 | 06-08-2009 06:11 AM |
| Want to replace characters | arndorff | Shell Programming and Scripting | 5 | 01-29-2008 04:05 PM |
| Replace string B depending on occurence of string A | hemangjani | Shell Programming and Scripting | 1 | 12-05-2006 05:10 PM |
| Replace Characters... | lgardner17325 | UNIX for Dummies Questions & Answers | 8 | 10-26-2006 05:04 PM |
| Replace characters in a string using their ascii value | roops | Shell Programming and Scripting | 2 | 03-04-2005 01:51 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Replace string and delete extra characters
Hopefully someone can help out here. This is probably fairly basic, but I've searched and tried several variations of the solutions presented in these forums, so I'll go ahead and ask.
How can I locate a string in a file, delete the characters after the string and then replace the string with a new string? Currently I have this, which is getting me close to a solution, but I can't get the extra characters removed: for file in test_program; do sed 's/OUTPUT='/'OUTPUT='$file/g $file > new_$file done Here is the test_program file that I am testing with: This is a test This is a test /OUTPUT=("This is a test") This is a test Here are the results after running my script: This is a test This is a test /OUTPUT=test_program("This is a test") This is a test I just need to have the script get rid of ("This is a test") and it will work fine for what I am trying to do, which is make this change to several thousand files at one time. Any assistance would be appreciated. I've got other ways to do this, but now that I've embarked down the Unix path, I want to see how this is done. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|