View Full Version : sed replace string of line
xaitax
June 19th, 2011, 06:54 PM
Hi,
i have a file with lots of lines like that
randomstring | randomstring
and i want to remove everything until the "|".
Any ideas how to do this with sed/awk?
TIA!
SevenMachines
June 19th, 2011, 07:28 PM
Been a while, would something like this not do it?
test.txt:
randomstring | randomstring
randomstring | randomstring
randomstring | randomstring
randomstring | randomstring
randomstring | randomstring
$ sed 's/.*\(|.*\)/\1/g' test.txt
| randomstring
| randomstring
| randomstring
| randomstring
| randomstring
I'm a little forgetful on the head twisting hieroglyphs of sed though :)
[EDIT] but
sed -i 's/.*\(|.*\)/\1/g' test.txt
for 'in place' editing obviously
geirha
June 19th, 2011, 07:30 PM
awk -F'|' '{print $NF}' file
sed 's/.*|//' file
ed -s file <<< $'g/.*|/s///\nw'
The last one edits the file.
Powered by vBulletin® Version 4.2.2 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.