Home » Infrastructure » Unix » Search and delete using sed command (Unix)
Search and delete using sed command [message #639294] Sun, 05 July 2015 02:58 Go to previous message
hemantakhandare@gmail.com
Messages: 5
Registered: March 2015
Location: Mumbai
Junior Member
Hi Experts ,

I want to search the pattern in and condition and then only delete that line containing that character string.

---------------------------------------------------------------------------------------------------
Input :
<POSLog><Transaction SourceSystem="1"><RetailStoreID StoreLanguageCode="1033">1030</RetailStoreID><RevenueCenterID>0</RevenueCenterID><WorkstationID>2</WorkstationID><RegisterTransactionNumber >306</RegisterTransactionNumber>
--------------------------------------------------------------------------------------------------

pattern to search is

grep -n 'RegisterTransactionNumber>306' sth_sample_data.dat |grep -n 'WorkstationID>2'|grep -n '1030</RetailStoreID>'

and using sed and I want to delete that line.

I tried many ways like below but it is not working correctly

sed -e '/RegisterTransactionNumber>306/d' -e 's/WorkstationID>2/d' sth_sample_data.dat>test1.dat_4

Can anyone provide help.
 
Read Message
Read Message
Previous Topic: asvc_t, wsvc_t values from iostat command output
Next Topic: Why oracle instance doesn't shutdwon after deleting system datafile?
Goto Forum:
  


Current Time: Fri Jan 17 19:15:35 CST 2020