-
I have file 203.195.159.11_2-day.png , i want to store 203.195.159.11_2-day only in my variable
My shells script :
a=0
for filename in *.png
do
a=filename---------------------Here I have to make some changes
convert $filename $filename".gif"
done
I want to store in variable a=203.195.159.11_2-day
Thanks
Paresh
-
for filename in `ls *.png`
do
a=`echo $filename | cut -d. -f1`
echo $a
done
-
for filename in `ls *.png`
do
a=`echo $filename | cut -d. -f1`
echo $a
done
I have aroung 30 .png files in the directory.
actually filename is 203.195.159.11_2-day.png
and I want to store 203.195.159.11_2-day
but your 3 rd statement actually stores 203 only.
Paresh
-
oh sorry, hadn't noticed all the dots in the filename
just use -f1-4 instead of -f1
BTW : this will only work if all your filenames are made of IP addresses, since it cuts using dot '.' as a field separator, and it takes the first 4 fields ... else you can do :
echo $^filename | sed 's/\.png$//'
-
Thanks PIPO
It worked
Paresh
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|