Something strange going on with a shell script I'm writing. It's trying to write a list of files that it finds in a given directory to another file. But I also have a skip list so matching files that are in that skip list should be, well uhm, skipped
Here's the code of my function:
Code:
build_file_list ()
{
FOLDER=${1}
if [ -d ${FOLDER} ]
then
##build find statement
SEARCH_STMT="find ${FOLDER} -type f ! -name \".*\" -mtime -${RETENTION} | egrep -vf ${SKIP_FILE}"
##SEARCH_STMT="find ${FOLDER} -type f ! -name \".*\" -mtime -${RETENTION}"
##find out if folder is serial or mfx
#echo ${FOLDER}
echo ${FOLDER} | grep /mfs/ >/dev/null
if [ $? -eq 0 ]
then
##folder is mfs, write to temp_mfs file
echo ${SEARCH_STMT} >> ${TEMP_MFS}
else
##folder is serial, write to temp_serial file
echo ${SEARCH_STMT}
${SEARCH_STMT} >> ${TEMP_SERIAL}
fi
fi
}
I've added an echo ${SEARCHT_STMT} for debugging reasons.
bash-3.00$ a="ls | grep txt"
bash-3.00$ echo $a
ls | grep txt
bash-3.00$ ${a}
|: No such file or directory
grep: No such file or directory
txt: No such file or directory
bash-3.00$ a="ls | grep txt"
bash-3.00$ eval $a
new.txt
old.txt
Hello
I have a shell script that is run as root. Script rins ok until the point where it have to switch to user "mqm" to run other commands. It just hangs at the point of this line in the script
su - mqm -c "dspmq"
I ran the same commands at the terminal and they run fine.
Any thoughts. (6 Replies)
Hi All,
I am using below snippet to search for a string (read from a file 'searchstring.out') in all locations (/) and then iterate over the files found to write the locations and the respective owner to an output file.
However, this doesn't work as I believe the find command doesn't exit's... (11 Replies)
I have 10 application servers in a distributed architecture generating their own application logs. Each server has application utility to continuously tail the log. for example following command follows tails and follows new logfiles as they are generated
server1$ logutility logtype
When I run... (8 Replies)
Linux version : Oracle Linux 6.4
Shell : Bash
The following script will be run as root. During the execution, it should switch to oracle user and execute few commands.
After googling and searching within unix.com , I came up with the following syntax
## Enclosing all commands in double... (7 Replies)
Howdie everyone...
I have a shell script RemoveFiles.sh
Inside this file, it only has two commands as below:
rm -f ../../reportToday/temp/*
rm -f ../../report/*
My problem is that when i execute this script, nothing happened. Files remained unremoved. I don't see any error message as it... (2 Replies)
Using solaris 2.5.1, and how can I get a summary of the size of each subdirectory, say for /export/home, all the users? usually I do a du -sk dirname but I have to manually type in each name, is there a better way?
Thanks, (3 Replies)
Hello,
I'm stuck and confused as to why when I execute things form the command line it works but when in a script it doesn't.
My script:
### creating a lock on the console
touch /var/run/console.lock
chmod 600 /var/run/console.lock
echo "$User" >>... (2 Replies)
I am trying to run the following code from a script file but it complains that syntax of (both instances of) grep is wrong.
When I copy and paste it to the terminal, it is OK. Any idea what the problem might be?
set i = `grep -c #define flags.h`
while ($i>20)
@ i--
my func (`cat... (4 Replies)