File mode badly shown in smbclient (want DAHR,---R,---- etc)

Joel Hammer jhammer2 at home.com
Thu Dec 20 06:53:09 GMT 2001


This is a new and improved version of that statement.
This should be easy to parse, no matter what awful file name you have.
 DEBUG(0,("  <%s>(%s)|%.0f|%s",   
Gives this output:
<junkbig.ps>()|31344767|Sat Dec  8 13:00:42 2001
<junkbig>()|31344767|Sat Dec  8 13:01:36 2001
<opera-6.0-20011129.1-static_qt.i386.tar.gz>()|4081948|Sun Dec  9 21:29:54 2001
<opera-6.0-20011129.1-static_qt.i386>(D)|0|Sun Dec  9 21:33:14 2001
<lib>(D)|0|Sun Dec  9 21:34:23 2001            

This is the sed command (very messy) which parses this for you:
#!/bin/bash
sed "{
s/\( *<\)\(.*\)\(>\)\((\)\(.*\)\()\)\(|\)\(.*\)\(|\)\(.*\)$/\"\2\" \"\5\" \"\8\"/
}"
It doesn't matter if there are embedded < or > in the file name. Sed goes
to the last character it can fit into the seach string.

This is the output:
"junkbig.ps" "" "31344767"
"junkbig" "" "31344767"
"opera-6.0-20011129.1-static_qt.i386.tar.gz" "" "4081948"
"opera-6.0-20011129.1-static_qt.i386" "D" "0"
"lib" "D" "0"                                                      

Ain't open source grand?
Joel





More information about the samba mailing list