It's actually an input field from a SQL script pulling the field from a mythTV database. The input field is identifying the episode number of total episodes. However as the input field is being sent as part of an EIT packet by the originating broadcaster you can't guarantee the format, thus the need to delete either 0 or whitespace etc.....
It's not homework, it's a script I'm working on as a process of trying to learn sed.
# cat infile
this is tab and zero 0 delete this zero
this is one zero 0 delete this zero
this is zero and tab 0 delete this zero
10 no delete this
10 no delete this
# sed 's/\(.*\)\b0\(.*\)/\1\2/' infile
this is tab and zero delete this zero
this is one zero delete this zero
this is zero and tab delete this zero
10 no delete this
10 no delete this
$
$
$ cat f1
this is tab and zero 0 delete this zero
this is one zero 0 delete this zero
this is zero and tab 0 delete this zero
0 this line has a leading zero
10 no delete this
10 no delete this
this line has a trailing zero 0
$
$
$ sed 's/\b0\b//g' f1
this is tab and zero delete this zero
this is one zero delete this zero
this is zero and tab delete this zero
this line has a leading zero
10 no delete this
10 no delete this
this line has a trailing zero
$
$
Franklin I used your example, can you please explain to me how yours is working?
The reason I ask is I really need to make sure any leading character (not just a tab) is catered for, it could be something stupid like a newline or a return or a space. I assume I need to add any 'possible' characters in the first square box field? TV companies are not renowned for their attention to detail when it comes to populating these data fields.
^\([ ]*\) # assign any existing spaces and tabs at the beginning of the line to the first remembered pattern (portion)
0 # there must be a 0 between the 1st and the next portion
\(.*\) # assign the remaining string after the 0 to the second portion
\1 # print the 1st portion
\2 # print the 2st portion