IB_88
April 25, 2014, 10:03am
1
Hi,
I am trying to add for loop in my code for all the .gz files in a directory.
example code:
for i in $PWD/input/*.dz
do
echo " file is :: $i "
done
This is not working as expectation and the output is :
file is :: /home/IB/input/*.dz
However, for i in $PWD/input/* is working fine. But this is not the requirement.
Please suggest
it will work.
Why you are using $PWD/input/*.dz
$PWD/input/*.dz
instead of
$PWD/input/*.gz
IB_88
April 25, 2014, 10:18am
3
that is typing mistake. I am using .gz
What do you have in the variable PWD
.
if echo $PWD
gives you /home/IB
and still the code is not working, try below
for i in $(ls $PWD/input/*.gz)
do
echo "file is :: ${i}"
done
That is a useless use of ls * . If it works at all, it will work without the ls!
for i in $PWD/input/*.gz
do
echo "file is :: ${i}"
done
Whenever a statement like that echoes "file is :: path/to/input/*.gz", that means, no files matched your expression, so doublecheck that you're looking where you think you are.
Exactly!!!
It is working for me
for i in $PWD/input/*.gz
do
echo " file is :: $i "
done
Make sure your present working directory contains directory
input
in otherway make sure you are running script one directory back from
input
directory