Searched a lot lot but didn't find any solution.
for example: if string is
a12345:hello world:hello world again:other stringoutput:
a12345::hello world again:other stringso I just wanted to delete the content between 1st and 2nd colon character
Any help would be appreciated.
Thanks,
2 Answers
Use sed:
sed 's/:[^:]*/:/'- first
:- match colon [^:]*- match any number of characters which are not a colon- last
:- replace the match with colon, because your match includes the first colon, but from your output I see you want to keep it.
Using sed:
sed -i 's/:[^:]*/:/' file_nameUsing awk:
awk -F':' -v OFS=":" '{$2="";print}' file_name 2