I'm not clear if a loop is needed for any reason, nor if by "touching" the file you want to change the date stamp in the name fo the file or just the atime, but this seems to be better handled by the find command, like "find from /app name *2008* | exec touch the file" .
But i was thinking in doing it with for loop so that i could have better chance to check if any of files in these directories misses out the touch command.
With touch i just wanted to the file to reflect the current sysdate and time.
i was thinking something like this
base_dir=/app/data
var1=/eng
var2=/med
var3=/bsc
for <list of direcotries> in <parentdir>
do
for i in *.20081230* // searchin each of directories /data ,/med, /bsc for files to touch
do
touch *
if [ -ne 0 ]
then
echo "failed to touch `$1` "
fi
done
But i was thinking in doing it with for loop so that i could have better chance to check if any of files in these directories misses out the touch command.
[/code]
What do you expect a failure of the touch command to tell you?
Quote:
[code]
With touch i just wanted to the file to reflect the current sysdate and time.
i was thinking something like this
Please put code inside [code] tags.
Quote:
Don't you mean:
Quote:
Why touch everything on every iteration of the loop?
If you do that, you will have no idea which file failed to be touched.
Quote:
Syntax error. That should be:
Quote:
That will try to execute the contents of $1 as a shell command. You mean:
Hello,
I'm a first time poster looking for help in scripting a task in my daily routine. I am new in unix but i am attracted to its use as a mac user.
Bear with me...
I have several files (20) that I manually drag via the mouse into several named directories over a network. I've used rsync... (14 Replies)
how can i move "dataName".sql.gz into a folder called 'database' and then move "$fileName".tar.gz * .htaccess into a folder called 'www' with the entire gzipped file being "$fileName".tar.gz? Is this doable or overly complex.
so
mydemo--2015-03-23-1500.tar.gz
> database
-... (5 Replies)
Hello
I have user directories that contain /temp directory.
Example folders:
/user1/temp/
/user2/temp/
/user3/temp/
How can i loop over all user directories and find all files only in their /temp folder?
Thanks a lot for help! (3 Replies)
Can anyone come up with a unix command that lists
all the files, directories and sub-directories in the current directory
except a folder called log.?
Thank you in advance. (7 Replies)
Hello,
Currently I have a painstaking process that I use to move file for a monthly archive. I have to run the same two commands for 24 different directories. I wish to have a script with a for loop automate this and I have not been able to succeed. Here is what I do 24 times. I know this is... (5 Replies)
I have the below directory in unix environment
/home/bkup/daily: ls -lrt
drwxrwx--x 2 user user 256 Jan 12 18:21 20110112/
drwxrwx--x 2 user user 256 Jan 13 17:06 20110113/
drwxrwx--x 2 user user 256 Jan 14 16:44 20110114/
drwxrwx--x 2 user user ... (2 Replies)
Hi,
I have various log files in different paths. e.g.
a/b/c/d/e/server.log
a/b/c/d/f/server.log
a/b/c/d/g/server.log
a/b/c/h/e/server.log
a/b/c/h/f/server.log
a/b/c/h/g/server.log
a/b/c/i/e/server.log
a/b/c/i/e/server.log
a/b/c/i/e/server.log
and above these have an archive folder... (6 Replies)
I have a folder with many subdirectories and i need to set the modified date to today for everything in it. Please help, thanks!
I tried something i found online, find . -print0 | xargs -r0 touch
but I got the error: xargs: illegal option -- r (5 Replies)
I'm trying to write a script that will loop through all files and directories down from a path I give it, and change the permissions and ACL. I was able to do the obvious way and change the files and folders on the same level as teh path...but I need it to continue on deeper into the file... (2 Replies)