Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
Pages: (5) </ 1 2 3 [4] 5 >/

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: "Add to filetool.lst" button, In emelfm?< Next Oldest | Next Newest >
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: April 30 2005,14:21 QUOTE

hey...that's cool.  I'd never heard of 'join'...or 'done'.
gonna need to read some more =o)

could you please verify a few things? (these are assumptions):
%d = `pwd`
join replaces grep
done checks the exit status of the last command

It looks like it's doing more work, but if it's faster it's better =o)


--------------
http://www.tldp.org/LDP/intro-linux/html/index.html
Back to top
Profile PM WEB 
WoofyDugfock Offline





Group: Members
Posts: 146
Joined: Sep. 2004
Posted: April 30 2005,16:31 QUOTE

Thx, I wouldn't have heard of `join' either except it was mentioned in passing recently in Linux Magazine (though they didn't use it this way) and I've been working hard on my bash (slow period at work!).

Quote
could you please verify a few things? (these are assumptions):
%d = `pwd`
join replaces grep
done checks the exit status of the last command


%d returns the active directory from emelfm while %f returns the basename of the file selected (emelfm help page) - so in this case the same result as `pwd`.

join file1 file 2 -- compares lines in both files, actually the default is to compare the first field in the line that ends with the first whitespace (ie in our case this compares whole lines).  If there is a match, it will append the remainder of the matching line in one file to the line in the other, except if the line in file 1 is identical to that in file 2 there's nothing to append and it won't double that line to output (so if the line is already in filetool.lst it won't be duplicated to stdout). One of these files can be stdin `-' ie the output from a pipe.  If there is no match it won't return anything, unless you use option `-a filenumber' ("append"), in which case it will append all of file1 to output. Since we use -a for both files, it will write the contents of both stdin and $a to the temp file, which then overwrites filetool.lst ie the line is written to filetool.lst just as desired. So used here, in short, it does replace "(test) grep pattern append || don't append ", but it's in one command. Clear as mud, I know. Took me a bit of thought, I haven't seen this anywhere (although it'd have to be around).

The "done" is just the "done" that terminates the "for" loop.

Though this use of "join" looks nice, I expected it to be slower than either Mik's grep test version or using "cat - $a|sort|uniq" (my first attempt - same result as join here except join puts the new lines at the beginning of filetool.lst) - but putting`time` in front of it suggested otherwise.


--------------
"We don't need no stinkin' Windows"

http://news.zdnet.co.uk/software/linuxunix/0,39020390,39149796,00.htm
Back to top
Profile PM 
mikshaw Offline





Group: Members
Posts: 4856
Joined: July 2004
Posted: April 30 2005,21:01 QUOTE

heh...i should have realized what "done" is.  From my first pre-coffee look, i was thinking it was an additional command =op

One thing to consider, though i don't know the whole story....
filetool.lst is executable.  I'm not sure why, but i assume there's a reason for it.  Does your script overwrite this permission when it overwrites the file?


--------------
http://www.tldp.org/LDP/intro-linux/html/index.html
Back to top
Profile PM WEB 
WoofyDugfock Offline





Group: Members
Posts: 146
Joined: Sep. 2004
Posted: May 01 2005,15:37 QUOTE

Hang on I've gotta think about it

--------------
"We don't need no stinkin' Windows"

http://news.zdnet.co.uk/software/linuxunix/0,39020390,39149796,00.htm
Back to top
Profile PM 
WoofyDugfock Offline





Group: Members
Posts: 146
Joined: Sep. 2004
Posted: May 01 2005,19:19 QUOTE

You must have been reading my thoughts because it occurred to me that overwriting filetool.lst was DUMB and redundant, let alone that temp file.  Just where does my brain go when it's not there? Dunno, I can't find it to tell me !!

I have a verson that doesn't use the temp file or overwrite filetool.lst either, but it's buggy and I've about had it for today.

Does anybody else think it's worth chewing on/comparing implementations like this - after all, if-grep does work ....? Regardless I intend to try to use this join trick to speed up a long script I'm writing that currently 'if-greps-appends-else' a lot on largish files....


--------------
"We don't need no stinkin' Windows"

http://news.zdnet.co.uk/software/linuxunix/0,39020390,39149796,00.htm
Back to top
Profile PM 
22 replies since Mar. 27 2005,02:19 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

Pages: (5) </ 1 2 3 [4] 5 >/
reply to topic new topic new poll
Quick Reply: "Add to filetool.lst" button

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code