Reputation: 71
I have a column of data of the form tt1234567 however some rows do not fill this criteria and I want to substitute this with a dash (-). Preferably this needs to be done only with unix tools.
at the moment I have sed -e 's/^(tt)/-'
But obviously that replaces everything starting with tt with dash, can i do the inverse command?
Upvotes: 1
Views: 51
Reputation: 195059
Very likely you are looking for this:
sed '/^tt/!s/.*/-/' file
For example:
kent$ cat f
tt123456
;alsjf
tt123456
kent$ sed '/^tt/!s/.*/-/' f
tt123456
-
tt123456
Upvotes: 1