October 20th, 2003, 07:21 PM
-
removing specific characters on the file
hi. im new with shell scripting, please help me out.
i need to make a script that will scan/parse one file and remove characters/word within that file.
for example, file "abcd" contains this text:
"abcdefghijklmnopqrs lmnopqrsabcdfghijk poiuytrewqabcdmnbvcxz"
i need to delete the string "abcd"and replace it with space , so that the output file looks like this:
" efghijklmnopqrs lmnopqrs fghijk poiuytrewq mnbvcxz"
im using HP-UX. thanks!
October 27th, 2003, 06:07 AM
-
you could try this perl statement. It works on Solaris. No promises for HP-UX though:
perl -i -pe "s/abcd/ /g" filename
December 5th, 2003, 04:06 AM
-
cat abcd.txt | sed "s/abcd/ /g" >>junk.txt; mv junk.txt abcd.txt;
if you donot want the file to be changed then you can simply use
cat abcd.txt| sed "s/abcd/ /g" to get the output
Regards
Regards
JK
December 5th, 2003, 06:01 AM
-
Originally posted by jayakhanna
cat abcd.txt | sed "s/abcd/ /g" >>junk.txt; mv junk.txt abcd.txt;
Use "cat junk.txt > abcd.txt" instead of the "mv" command. This way will not change the file's permissions.
hth,
M.