So you know the problem. It should be a filename and not directory name.
Also, in that way, you are actually trying to decompress the directory also (and not storing the decompressed files to that directory which I think you want to)
check man gzip or man gunzip for details.
Basically, you need to
for i in *.gz
do
gzip -dc $i > /location/of/unzipped/files/individual_file_name.txt
done
In your case,
for i in *.gz
do
gzip -dc $i > /home/vizion/Desktop/gzipfile/${i%.gz}
done
I assumed you are executing the script from the current directory. Otherwise, $i would contain absolute paths and you need to handle that as well.
Also, you dont need to use -d with gunzip . gunzip = gzip -d
When i am running the script it's working as expected. but when i am given absolute path of .gz files getting the error "./exa2: line 2: /home/vizion/Desktop/gzipfile//home/vizion/Desktop/*: No such file or directory"
code as below
#!/bin/sh
for i in '/home/vizion/Desktop/*.gz' ; do gzip -dc $i > /home/vizion/Desktop/gzipfile/${i%.gz} ; done
You should NOT use the quotes as they wont be expended as wildcard (*). The above would loop only once containing /home/vizion/Desktop/*.gz in $i hence that error.
For absolute path, I already asked you to work on that if required. You need to extract the filename from the path.
Anyway,
for i in /home/vizion/Desktop/*.gz
do
fname=${i##*/}
fname_without_gz=${fname%.gz}
gzip -dc $i > /home/vizion/Desktop/gzipfile/${fname_without_gz%.gz}
done
I have used multiple variable for readability. You can override the same variable if you want.