[plug] A bit of gross bash code

The Thought Assassin assassin at live.wasp.net.au
Wed Mar 7 16:26:55 WST 2001


On Wed, 7 Mar 2001, Brad Campbell wrote:
> Ok, I'm sure you have had enough of me today, but here is a bit
> of bash code I wrote to solve a problem..
> Question is, is there an easier way to do this.. or am I on the right
> track. I mean, it works, but it's very rough.
> it takes an ls -la /dev
> crw--w--w-    1 0        5         29,  28 Feb 23  1999 fbuser4
> crw--w--w-    1 0        5         29,  29 Feb 23  1999 fbuser5
> and generates an : delimited file for me to parse later
> c:0:5:29:28:fbuser4
> c:0:5:29:29:fbuser5
> You get the idea.. it does this for types c,u & b

OK, it's definitely "quick and dirty", but it's a start:

ls -ln /dev|
grep "^[c|b|u]" |tr -s " ", ":"|cut -d: -f1,3,4,5,6,10 |cut -c1,11-

one caveat is that it will choke on files with spaces or colons in them.

-Greg Mildenhall




More information about the plug mailing list