Thanks Corona688,
I need to select only files modified since last x days, this is why in the first post you can see -mtime -nbdays
on my find command.
And Yes .sf are files.
I don't understand the section :
# Add .sfd to list if exists, .sf if not
I need to generate 1 tar file that will contain all files selected (.sfd).
1 - find all .sf file modified since last 2 years
2- with that list of files, see if a file (same filename) but with the extension .sfd exist. if the .sfd exist keep only the .sfd file.. IF not exist skip the file and process the next .sf file.
thank you
---------- Post updated at 12:47 PM ---------- Previous update was at 12:08 PM ----------
Corona688,
the fact that I'm just a beginner in Unix, I just understand what you saying..
FILES="$FILES $FILE"
At the end, $FILES with contain all .sfd file picked ||
Just need to be able to select only files (.sf) where the last mods date is max 2 years.
thanks
---------- Post updated at 01:09 PM ---------- Previous update was at 12:47 PM ----------
I tried the commands (from Corona688) and I got the error :
The specified substitution is not valid for this command.
related to the line :
FILE2="${FILE/.sf}".sfd
thanks
---------- Post updated at 02:01 PM ---------- Previous update was at 01:09 PM ----------
Hello,
I find a way to replace the .sf by .sfd without error by usinf sed
.
FILES=""
for FILE in *.sf
do
FILE2=`echo $FILE | sed 's/\.sf/.sfd/g'`
[ -e "$FILE2" ] && FILE="$FILE2"
FILES="$FILES $FILE"
done
echo tar -cf - $FILES
Now, what is missing is the way to select only files (.sf) where the last mod date is 2 years.
Something similar that I did in a find command, but need to be done in the FOR command that Corona688 gave us.
Something similar to :
find *.sf -type f -mtime -$nb_days | ...
thanks a lot