how do i kill a process from inside a bash script?
hi!
i'm a newbie at bash scripting but i think it's a powerful way of getting some things done. anyway i'm writing a sort of `database' script and i'm using `find' to look for certain files. the problem is that find looks for all occurences of the file i'm looking for and so it takes too long to finish! is there some sort of way to kill `find' after it has located the first occurence of the file? thanks! -mike |
I don't use find, but you can try piping into head...
find file | head -n 1 |
thanks for the reply. i can actually "work" on each line of `find's output using by pipint to `xargs' but then find would still be running in the background. what i'd need to do is actually stop find from executing after it has found the first item.
:D |
Hi,
ranger_nemo advised you good. Try that command - it will output just first occurence of what you are looking for and then exit. It's because head -n 1 exits after processing first line of its input and therefore bash stops also command find. Ma3oiS |
You can check it with time...
Code:
$ time locate png |
All times are GMT -5. The time now is 07:11 PM. |