I want to cut all the digits from the beginning of each line up to ":" character and to have everything like this :
line1
line2
line3
.....
linen
P.S : content of line1 ... linen may contain ":" character so to eliminate what I don;t want from each line with echo $line | cut -d ":" -f 2 will not work well.
sorry , but I didn't see your important note that the lines may contain another ":" , my first code will not work if this is true ,kindly use below python code:
import re
fin = open("infile.txt",'r')
fout = open("outfile.txt",'w')
for line in fin:
print(re.subn(r".*?:","",line,count=1)[0] , file=fout , end="")
fin.close()
fout.close()
BR
---------- Post updated at 17:47 ---------- Previous update was at 17:42 ----------
this will not work for below:
using bash:
$ echo "765327564:line1 hdvir:kvoir" | sed 's/.*://'
kvoir