Jump to content

problem with shell script to send find to awk


crp

Recommended Posts

mDoW="`date | cut -c 1-3`"
mkdir /home/bu_files/$mDoW/
find /mnt/SAC/* -mtime -1 | awk '{print "cp " "\"$_"\" " /home/bu_files/"$mDoW}'

results in

awk: line 1: runaway string constant "$mDoW} ...

Anyone know how to fix it? using Debian Whiskey.

Edited by crp
Link to comment
Share on other sites

What are you trying to accomplish with your script?

 

You can the get the day of the week from date without using cut:

 

mDow=$(date +%a)
echo $mDow
Sat

  • Like 1
Link to comment
Share on other sites

What are you trying to accomplish with your script?

 

You can the get the day of the week from date without using cut:

 

mDow=$(date +%a)
echo $mDow
Sat

copy new files from today to a directory with the day's name as part of the directory name.

This is simple enough in the DOS world with xcopy but I can't find an equivalent in Linux.

My quote marks seem to be aligned properly but the macro expansions are not functioning.

Link to comment
Share on other sites

I gave up on it, after a lot of toil came up with

find /mnt/SAC/* -type f -mtime -1 -exec cp -u -v -b -p --parents {} /home/bu_files/_$mDoW/ \;

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...