When I execute this line at the command prompt I get a different answer than when I run it in a script? Any ideas on how to resolve? I'm trying to find all files/dir in a directory except files that start with the word file.
Once I get this command to work, I will add the "delete" part to the command. Just trying to make sure I have all the right files listed first.
The syntax is kind of oddball, and chances are your interactive script is executed by something like ksh or bash, whereas your script is presumably executed by /bin/sh.
In particular, I imagine the unquoted exclamation mark might have some unseen side effects.
Try fix the find command to adhere to the spec:
Also investigate whether the PATH is somehow different inside the script, and/or you have functions or aliases which interfere in the interactive shell.
Is your shebang line different from your login shell. Maybe the ! is having unwanted side effects and since your are interested only in files add the -type switch too.
Franklin52: That's not it, single quotes are stronger than double, so the result should be the same (you want to prevent the asterisk from being expanded by the shell).
blt123: can you run the interactive shell with -x too?
See the + lines there? You can get them from an interactive session just like from a script. (No need to start a subshell either, you can just say set -x to enable them; set +x to turn them back off.)
The crucial question is whether the find command gets expanded to something unexpected.
Also, can you try with a hard-coded path to your find binary (/usr/bin/find I would guess)?
Under one of my directories on server I have more than 500 files with different type and name. When I run the find command to list the files with 'ABC_DEFGH' in the begining of its name and older than 20 days, nothing is return as result. Though I know there are more than 400 files which their name... (10 Replies)
Hello,
Hitting a wall on this one. When at the command prompt it works fine:
# find /home/testuser -name 'PAINT*canvasON.txt'
/home/testuser/PAINT_canvasON.txt
# pwd
/home/testuser
# ls -l PAINT*canvasON.txt
-rw-r--r-- 1 root user 23 Feb 07 02:58 PAINT_canvasON.txt... (2 Replies)
Hi Gurus.
This is driving me a bit batty. I now if must be a simple matter but I cant find anything that references it.
I have a housekeeping script that searches for some huge dump directories then removes them using rm -rf.
find ./ -name 'ab' -exec rm -rf {} \;
This works but always... (7 Replies)
Hi,
Need help with a sed command that I am using to substitute 3 positions of a pipe delimited file.
i am getting different results while substituting the same position of two different files with the same value. Please see details below:
$ cat chk2
... (3 Replies)
Hi all!
I've faced with very unintelligible error using find/grep like this:
root@v29221:~# find /var/www/igor/data/www/lestnitsa.ru | grep u28507I get nothing as a result, but:
root@v29221:~# grep u28507 /var/www/igor/data/www/lestnitsa.ru/_var.inc
$db_name = 'u28507';... (2 Replies)
Hi,
How do you echo something once when a find statement returns null results?
This is when using mutiple locations and mutiple arguments.
The below find command the inner loop of a nested for loop where the outter loop holds the $args and the inner loop holds the locations.
find... (2 Replies)
Hi guys.
I am trying, to move files found with the find command...
Script runs fine, until it reaches a file that contains spaces...
Here is what i wrote up quickly.
ROOTDIR=/apps/data
SEARCH=$(find /data/HDTMPRestore/home/tmq/ -type f -print | grep Mods/Input/bck | cut -c19-)
for i... (1 Reply)
This is my list of sed commands: can anyone tell me where im going wrong. The script works on a file called data which contains 6 student id's and there answers for 6 questions.
!/bin/sh
sed -e 's/*//g' \ #replace * with nothing
-e s/ /X/g' \ #replacing empty space with X
-e... (2 Replies)