[Nottingham] Quick! I need a bash one liner!

Martin martin at ml1.co.uk
Tue Feb 1 16:34:14 GMT 2005


Michael Erskine wrote:
[...]
> 
> #!/bin/bash
> for file in *.[ch] 
> do
>  expand -t 4 $file > t1
>  mv t1 $file
> done


As a 'one liner':

for file in *.[ch] ; do mv $file $file.bak ; expand -t 4 $file.bak 
 >$file ; done

And to save retyping it each time, add it into your .bashrc as an alias:

alias ctabs='for file in *.[ch] ; do mv $file $file.bak ; expand -t 4 
$file.bak >$file ; done'



> ...I guess this probably worked (not checked yet! I'd like to grep for '\t' 
> but it doesn't seem to act like perl and grep -P says "not supported") but 
> I'm curious whether this "script" can be issued as a one-liner - anyone?

???

grep & egrep will search for tabs:

egrep -e '\t' yourtabbedfile

works as expected.


Good luck,
Martin

-- 
----------------
Martin Lomas
martin at ml1.co.uk
----------------



More information about the Nottingham mailing list