![]() |
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 |
| automating file search and replace text | ommatidia | Shell Programming and Scripting | 3 | 02-28-2008 04:40 PM |
| Perl: Search for string on line then search and replace text | Crypto | Shell Programming and Scripting | 4 | 01-04-2008 10:24 AM |
| Search and replace in file.. | Amits | Shell Programming and Scripting | 2 | 08-22-2006 07:11 PM |
| Search and replace multi-line text in files | marz | Shell Programming and Scripting | 10 | 10-10-2005 08:05 AM |
| How do you search and replace a text with markerA that end with markerB | drone | Shell Programming and Scripting | 1 | 06-19-2003 09:12 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
How to search and replace text in same file
script is as below
v_process_run=5 typeset -i p_cnt=0 pdata=/home/proc_data.log while [ $p_cnt -le $v_process_run ] do # execute script in background dummy_test.sh "a1" "a2" & p_cnt=$p_cnt+1 echo "data : $p_cnt : Y" >> $pdata done file created with following data in /home/proc_data.log data : 1 : Y data : 2 : Y data : 3 : Y data : 4 : Y data : 5 : Y now when each background process is completed want to delete the line for matching pattern from log file without redirecting to new file ( below command is not working , please suggest) for example : grep "data : 3 : Y" /home/proc_data.log | sed "/data : 3 : Y/d" or now when each background process is completed want to update the line for that process from log file without redirecting to new file ( please suggest); search for : data : 3 : Y and relace with : data : 3 : N hence output in the file should be data : 1 : Y data : 2 : Y data : 3 : N data : 4 : Y data : 5 : Y |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|