How to remove the trailing slash from a variable which defines a directory from a time test output
2
votes
1
answer
3526
views
Ubuntu 16.04
Even thou the output of for
client in */; do
doesn't produce a trailing slash, the trailing slash appears if I echo the variable $client while performing a time test on the file, within the loop.
cd "$wDir"
for client in */; do
cd "$wDir"/"$client";
#-- check to see if any .csv files exists
if ls *.csv &>/dev/null; then
for csvfile in *.csv; do
if test $(find "$csvfile" -mmin +2880); then
echo "$client has files older than 2 days ..." >> "staleFtpAccts"
fi
done
fi
done
When I execute the script, a / is placed after the $client variable like so:
root@me /home/frank # bash script.sh
Start ...
000029_000020/ has files older than 2 days ...
#--
Finished ...
Start ...
000033_000040/ has files older than 2 days ...
#--
Finished ...
Start ...
000033_000041/ has files older than 2 days ...
#--
Finished ...
Start ...
000033_000042/ has files older than 2 days ...
#--
Finished ...
Start ...
000033_000043/ has files older than 2 days ...
#--
Finished ...
This is the result I am after ...
root@me /home/frank # bash script.sh
Start ...
000029_000020 has files older than 2 days ...
#--
Finished ...
Start ...
000033_000040 has files older than 2 days ...
#--
Finished ...
Start ...
000033_000041 has files older than 2 days ...
#--
Finished ...
Start ...
000033_000042 has files older than 2 days ...
#--
Finished ...
Start ...
000033_000043 has files older than 2 days ...
#--
Finished ...
Asked by Vituvo
(411 rep)
Mar 23, 2018, 02:50 PM
Last activity: Mar 23, 2018, 04:20 PM
Last activity: Mar 23, 2018, 04:20 PM