osx - search and remove string with variable parameters -
i need remove strings text file using command line on osx.
the string have permanent features have arbitrary digits.
i want remove every variant of :-
[370.15 kkey/s][total 2999999][prob 0.0%][50% in 7.8h]
this string has varying values want remove leaving relevant information in sections labled:-
pattern1 : code : codehash : result :
the following mock procedure needs happen
each line{ if string contains [%d%d%d.%d%d kkey/s][total %d%d%d%d%d%d%d][prob %d.%d%][%d%d% in %d.%dh] (where "%d" decimal value){ delete string , line } else if !contains { move down 1 line. } {
with below text patterns , hashes should saved text document
[370.15 kkey/s][total 2999999][prob 0.0%][50% in 7.8h] [370.02 kkey/s][total 3000368][prob 0.0%][50% in 7.8h] [323.02 kkey/s][total 3001368][prob 0.0%][50% in 7.8h] [389.02 kkey/s][total 3003368][prob 0.0%][50% in 7.8h] [379.06 kkey/s][total 3003368][prob 0.0%][50% in 7.8h] [300.01 kkey/s][total 3004368][prob 0.0%][50% in 7.8h] [379.02 kkey/s][total 3005368][prob 0.0%][50% in 7.8h] [279.02 kkey/s][total 3006368][prob 0.0%][50% in 7.8h] [179.02 kkey/s][total 3007898][prob 0.0%][50% in 7.8h] pattern1: want keep text after pattern , code until next line of processing including hash code : aksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsd codehash : e3287cb701f336a628885e66d17e38f2 result : d0b6789d4e0acf39a8c24b424c0060ffff2da857 [370.15 kkey/s][total 2999999][prob 0.0%][50% in 7.8h] [370.02 kkey/s][total 3000368][prob 0.0%][50% in 7.8h] [323.02 kkey/s][total 3001368][prob 0.0%][50% in 7.8h] [389.02 kkey/s][total 3003368][prob 0.0%][50% in 7.8h] [379.06 kkey/s][total 3003368][prob 0.0%][50% in 7.8h] [300.01 kkey/s][total 3004368][prob 0.0%][50% in 7.8h] [379.02 kkey/s][total 3005368][prob 0.0%][50% in 7.8h] [279.02 kkey/s][total 3006368][prob 0.0%][50% in 7.8h] [179.02 kkey/s][total 3007898][prob 0.0%][50% in 7.8h] [370.15 kkey/s][total 2999999][prob 0.0%][50% in 7.8h] [370.02 kkey/s][total 3000368][prob 0.0%][50% in 7.8h] [323.02 kkey/s][total 3001368][prob 0.0%][50% in 7.8h] [389.02 kkey/s][total 3003368][prob 0.0%][50% in 7.8h] [379.06 kkey/s][total 3003368][prob 0.0%][50% in 7.8h] [300.01 kkey/s][total 3004368][prob 0.0%][50% in 7.8h] [379.02 kkey/s][total 3005368][prob 0.0%][50% in 7.8h] [279.02 kkey/s][total 3006368][prob 0.0%][50% in 7.8h] [179.02 kkey/s][total 3007898][prob 0.0%][50% in 7.8h] [370.15 kkey/s][total 2999999][prob 0.0%][50% in 7.8h] [370.02 kkey/s][total 3000368][prob 0.0%][50% in 7.8h] [323.02 kkey/s][total 3001368][prob 0.0%][50% in 7.8h] [389.02 kkey/s][total 3003368][prob 0.0%][50% in 7.8h] [379.06 kkey/s][total 3003368][prob 0.0%][50% in 7.8h] [300.01 kkey/s][total 3004368][prob 0.0%][50% in 7.8h] [379.02 kkey/s][total 3005368][prob 0.0%][50% in 7.8h] [279.02 kkey/s][total 3006368][prob 0.0%][50% in 7.8h] [179.02 kkey/s][total 3007898][prob 0.0%][50% in 7.8h] [370.15 kkey/s][total 2999999][prob 0.0%][50% in 7.8h] [370.02 kkey/s][total 3000368][prob 0.0%][50% in 7.8h] [323.02 kkey/s][total 3001368][prob 0.0%][50% in 7.8h] [389.02 kkey/s][total 3003368][prob 0.0%][50% in 7.8h] [379.06 kkey/s][total 3003368][prob 0.0%][50% in 7.8h] [300.01 kkey/s][total 3004368][prob 0.0%][50% in 7.8h] [379.02 kkey/s][total 3005368][prob 0.0%][50% in 7.8h] [279.02 kkey/s][total 3006368][prob 0.0%][50% in 7.8h] [179.02 kkey/s][total 3007898][prob 0.0%][50% in 7.8h] pattern2: want keep text after pattern , code until next line of processing including hash code : qwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrq codehash : 05bfabd43ff6c85a8fa2d3347d828c4b result : 165b6ca902e567959c9bb599fabeb3998b21e31f [370.15 kkey/s][total 2999999][prob 0.0%][50% in 7.8h] [370.02 kkey/s][total 3000368][prob 0.0%][50% in 7.8h] [323.02 kkey/s][total 3001368][prob 0.0%][50% in 7.8h] [389.02 kkey/s][total 3003368][prob 0.0%][50% in 7.8h] [379.06 kkey/s][total 3003368][prob 0.0%][50% in 7.8h] [300.01 kkey/s][total 3004368][prob 0.0%][50% in 7.8h] [379.02 kkey/s][total 3005368][prob 0.0%][50% in 7.8h] [279.02 kkey/s][total 3006368][prob 0.0%][50% in 7.8h] [179.02 kkey/s][total 3007898][prob 0.0%][50% in 7.8h] [370.15 kkey/s][total 2999999][prob 0.0%][50% in 7.8h] [370.02 kkey/s][total 3000368][prob 0.0%][50% in 7.8h] [323.02 kkey/s][total 3001368][prob 0.0%][50% in 7.8h] [389.02 kkey/s][total 3003368][prob 0.0%][50% in 7.8h] [379.06 kkey/s][total 3003368][prob 0.0%][50% in 7.8h] [300.01 kkey/s][total 3004368][prob 0.0%][50% in 7.8h] [379.02 kkey/s][total 3005368][prob 0.0%][50% in 7.8h] [279.02 kkey/s][total 3006368][prob 0.0%][50% in 7.8h] [179.02 kkey/s][total 3007898][prob 0.0%][50% in 7.8h] [370.15 kkey/s][total 2999999][prob 0.0%][50% in 7.8h] [370.02 kkey/s][total 3000368][prob 0.0%][50% in 7.8h] [323.02 kkey/s][total 3001368][prob 0.0%][50% in 7.8h] [389.02 kkey/s][total 3003368][prob 0.0%][50% in 7.8h] [379.06 kkey/s][total 3003368][prob 0.0%][50% in 7.8h] [300.01 kkey/s][total 3004368][prob 0.0%][50% in 7.8h] [379.02 kkey/s][total 3005368][prob 0.0%][50% in 7.8h] [279.02 kkey/s][total 3006368][prob 0.0%][50% in 7.8h] [179.02 kkey/s][total 3007898][prob 0.0%][50% in 7.8h] [370.15 kkey/s][total 2999999][prob 0.0%][50% in 7.8h] [370.02 kkey/s][total 3000368][prob 0.0%][50% in 7.8h] [323.02 kkey/s][total 3001368][prob 0.0%][50% in 7.8h] [389.02 kkey/s][total 3003368][prob 0.0%][50% in 7.8h] [379.06 kkey/s][total 3003368][prob 0.0%][50% in 7.8h] [300.01 kkey/s][total 3004368][prob 0.0%][50% in 7.8h] [379.02 kkey/s][total 3005368][prob 0.0%][50% in 7.8h] [279.02 kkey/s][total 3006368][prob 0.0%][50% in 7.8h] [179.02 kkey/s][total 3007898][prob 0.0%][50% in 7.8h] [370.15 kkey/s][total 2999999][prob 0.0%][50% in 7.8h] [370.02 kkey/s][total 3000368][prob 0.0%][50% in 7.8h] [323.02 kkey/s][total 3001368][prob 0.0%][50% in 7.8h] [389.02 kkey/s][total 3003368][prob 0.0%][50% in 7.8h] [379.06 kkey/s][total 3003368][prob 0.0%][50% in 7.8h] [300.01 kkey/s][total 3004368][prob 0.0%][50% in 7.8h] [379.02 kkey/s][total 3005368][prob 0.0%][50% in 7.8h] [279.02 kkey/s][total 3006368][prob 0.0%][50% in 7.8h] [179.02 kkey/s][total 3007898][prob 0.0%][50% in 7.8h]
leaving resulting text document this:-
pattern1 : want keep text after pattern , code until next line of processing including hash code : aksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsdaksjhdakjsdhakshdkasdhkashkjahsd codehash : e3287cb701f336a628885e66d17e38f2 result : d0b6789d4e0acf39a8c24b424c0060ffff2da857 pattern2 : want keep text after pattern , code until next line of processing including hash code : qwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrqgfqwfufiyfoqywfofqwytrq codehash: 05bfabd43ff6c85a8fa2d3347d828c4b result : 165b6ca902e567959c9bb599fabeb3998b21e31f
i have used sed remove single characters so:-
sed -i '' 's/%/\ /g' file.txt sed -i '' 's/\[/\ /g' file.txt sed -i '' 's/]/\ /g' file.txt sed -i '' 's/kkey\/s/\ /g' file.txt
while works symbols cant guess numbers or sed out numbers incase within the important strings , sed replaces it!
with above routine in mind how approach this??
many in advance can offer
you can use grep
-v
:
grep -v 'kkey/s.*total.*prob' < input > output
or if want remove blank lines too:
egrep '^[ \t]*(pattern1|code|codehash|result) : ' < input > output
Comments
Post a Comment