mikshaw
Group: Members
Posts: 4856
Joined: July 2004 |
|
Posted: Mar. 27 2005,16:00 |
|
Rogue Streak:
Configure/Buttons/Add... command: [removed -- see below]
I'm not sure if the preceding slash is a problem. if so you might need to change the command a bit.
EDIT: That didn't work with multiple files, but this one will. It also removes the leading slash.
Code Sample | for i in %f; do grep `pwd|cut -c 2-`/$i /home/dsl/filetool.lst || echo `pwd|cut -c 2-`/$i >>/home/dsl/filetool.lst; done |
EDIT2: In case you are interested in learning some script (and since i'm just twiddling my thumbs on a sunday afternoon), i'll try to break this down for you....
It uses a "for" loop, which basically does everything within the loop, applied to whatever immediately follows "for". In this case it is $i, which is a variable that contains the selected file(s). EmelFM uses %f to specify the files selected. If there are multiple files selected, %f would be a list of all those files. So $i represents the list of files, one at a time. Example: foo, bar, and foobar are selected, so %f would be "foo bar foobar". "for i in %f" would be the same as "for i in foo bar foobar", which says "do the upcoming actions for foo, then bar, then foobar".
`pwd|cut -c 2-`/$i pwd returns the current directory, which is piped to cut. Cut returns everything from the second character on to the end of the line, and /$i appends a slash and the selected file. The backticks say "do everything in the backticks as a command, and the result is what we work with". So if "foo" is the currently selected file, and the current directory is /usr/bin, then it would do this: 1) pwd = /usr/bin 2) cut -c 2- = usr/bin 3) /$i = /foo 4) result: usr/bin/foo
Grep looks for the result (usr/bin/foo) in /home/dsl/filetool.lst
the "||" means "or". If the grep succeeds, the following command is not run. If the grep fails, then "echo usr/bin/foo >>/home/dsl/filetool.lst" is run. This appends usr/bin/foo to filetool.lst
-------------- http://www.tldp.org/LDP/intro-linux/html/index.html
|