Delete one Line from Main File and Create another
Hi
I need to write a script which will search for some text in some CSV files and will delete the record/line with the matching text and will insert that record/line into some other file.
Can you please help?
Here is what I want: -
Contents of MainFile.csv: -
1,2,3,Loan,4,5,6
1,2,3,Loan,4,5,6
1,2,3,Bank,4,5,6
1,2,3,Bank,4,5,6
1,2,3,Cheque,4,5,6
1,2,3,Cheque,4,5,6
I wish to search the current directory and file out which all files contain the text "Cheque" and I wish to delete these records from all the files and thus MainFile.csv will become
Contents of MainFile.csv: -
1,2,3,Loan,4,5,6
1,2,3,Loan,4,5,6
1,2,3,Bank,4,5,6
1,2,3,Bank,4,5,6
and another file should be created TEMP.CSV with following contents: -
1,2,3,Cheque,4,5,6
1,2,3,Cheque,4,5,6
Can you please help me how to do this?