how to unzip File which has no extension


 
Thread Tools Search this Thread
Operating Systems Solaris how to unzip File which has no extension
# 8  
Old 11-27-2007
something like this?

for i in `ls -1`
do
gunzip -c $i > /path/to/file/$i
done

not tested!

Last edited by DukeNuke2; 11-27-2007 at 10:25 AM..
# 9  
Old 11-27-2007
duke, above script works. In fact, it only works if i run it from the same archive dir. now i need more help from you. suppose, filename= unixtt* i have thousand gziped unixtt* files in a directory called /home/thousand/gzipfiles/
But in that directory there Remaining several unixtt* files that are already been UnZip and some files with Different file name like exyz*. In that case, i cannot use variable $i in the script.

I now want to unzip the unixtt* files and send it to /some/other/directory/sameas/unixtt*

what could be the better script for the above situation? I would like to run that script from different directory.

//purple
# 10  
Old 11-27-2007
Quote:
But in that directory there Remaining several unixtt* files that are already been UnZip and some files with Different file name like exyz*. In that case, i cannot use variable $i in the script.
What does prevent you moving first the unzipped and other files out from /home/thousand/gzipfiles/ to a different directory /home/thousand/temp_dir/ , and then continuing unzipping the left-overs zipped files using the above for script.

Code:
mv unixtt1 unixtt2 ... unixttN exyz1 ... exyzN...  /home/thousand/temp_dir  

or if the unzipped files can be grouped together somehow, use a for loop for them, say:

Code:
for files in `ls unix*`
do
mv $files   /home/thousand/temp_dir
done

After you're done unzipping move the files to the same directory again.

Last edited by rubionis; 04-15-2008 at 06:53 PM.. Reason: code tags
# 11  
Old 11-27-2007
unzip

Quote:
Originally Posted by rubionis
for files in `ls unix*`
do
mv $files /home/thousand/temp_dir
done
Yap its good idea to use loop for moving files. So can do the below lines in same script ??--
-------------------
!#/usr/sh/

for files in `ls unix*`
do
mv $files /home/thousand/temp_dir
done

for i in `ls -1`
do
gunzip -c $i > /path/to/file/$i
done
--------------

above script will work if i run it from the same archive directory. But i want to run the script from Another directory. Then what should i change in the script ???
# 12  
Old 11-27-2007
work with an option (the path where to look)!

like this:

#yourscript.sh /path/to/files

and call the path in your script like this:

mv ${1}/${files} /home/thousand/temp_dir
# 13  
Old 11-27-2007
Quote:
above script will work if i run it from the same archive directory. But i want to run the script from Another directory. Then what should i change in the script ???
Simple, copy your script to a different dir:

Code:
cp -p gunzip_script   /home/thousand/other_dir/

then slightly modify your script adding cd to gzipfiles directory, and executing the script now from the other directory. Then remove the previous old script.

Code:
cd /home/thousand/gzipfiles
for i in `ls -1`
do
gunzip -c $i > /path/to/file/$i
done


Now regarding moving files, that depends on your specific situation, I brought my moving script simply as an example. You have to find a way how to group your files that you need to move: unixtt* and exyz*, using grep or some other utility.

So I would it in 2 steps. Execute the scripts separately. First the move script then use the unzip script.

If you can't find a way how to group the files move them manually:

Code:
mv unixtt1 unixtt2 ... unixttN exyz1 ... exyzN... /home/thousand/temp_dir


Last edited by rubionis; 04-15-2008 at 06:50 PM.. Reason: code tags
# 14  
Old 11-29-2007
Hi rubionis,

its works well. Many thanks. Below script i run from other directory and works. The reason Not to run the script from the same archive file directory is - unix system also trying to unzip the scritname (myscript.sh) as well. Becuase in shell we put $i, which means any file.


----
#!/usr/bin/sh
cd /home/thousands/gzipfiles/
for i in `ls -1`
do
gunzip -c $i > /path/to/file/$i
done
----
In my directory there some GZIP file and also normal data files with same name unixtt* Is it possible I can just unzip only GZIP unixtt* files leaving the data unixtt* files.??

Last edited by thepurple; 11-29-2007 at 05:52 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unzip a gz file

Please tell me the unix command how to unzip a gz file(say a qwe.gz) and the orginal gz file should remain intact. Thanks in advance (7 Replies)
Discussion started by: pranabpal
7 Replies

2. UNIX for Dummies Questions & Answers

Display the .csv extension files based on .done extension fine

Hi All, I want to fetch the files based on .done file and display the .csv files and Wil take .csv files for processing. 1.I need to display the .done files from the directory. 2.next i need to search for the .Csv files based on .done file.then move .csv files for the one directory ... (2 Replies)
Discussion started by: girija.g6
2 Replies

3. Shell Programming and Scripting

Unzip the .zip file without using unzip utility in UNIX

I have .zip file, i want to list all the files archived in the zip file. unzip utility is not working for me in unix. Please help me resolve this issue Thanks ganesh. (3 Replies)
Discussion started by: Ganesh L
3 Replies

4. UNIX for Dummies Questions & Answers

unzip single file in zip file to STDOUT

Hi, Does anyone know if there is an unzip command similar to tar -xOf $tarBall $fileInTarFile which will untar a single file in a tar ball to STDOUT ? I want to do the same but with a .zip (ZIP archive) file. - Andy ---------- Post updated at 05:56 PM ---------- Previous update... (0 Replies)
Discussion started by: andyatit
0 Replies

5. Shell Programming and Scripting

How to Unzip a file using unzip utility for files zipped without zip utility ?

Hi, I need to zip/compress a data file and send to a vendor. The vendor does have only unzip utility and can accept only .ZIP files. I do not have zip utility in my server. How do I zip/compress the file so that it can be deflated using unzip command ? I tried gzip & compress commands, but... (1 Reply)
Discussion started by: Sabari Nath S
1 Replies

6. UNIX for Advanced & Expert Users

How can i unzip .gz extension file?

I have pulled a .gz file from UNIX to window. Is there way to unzip UNIX based file on window? Thanks advance. (9 Replies)
Discussion started by: J_ang
9 Replies

7. Shell Programming and Scripting

How to unzip the file

Hi, I have a file in the form of .zip in unix directory, now I want to unzip the file in unix environment. May I know how to unzip this file File name: cust.zip Thanks in Advance... Aswice (1 Reply)
Discussion started by: aswice
1 Replies

8. Shell Programming and Scripting

How to Unzip a .ZIP file in Unix without using unzip cmd..?????

Hi All I have ftped a .ZIP file (zipped using WinZip in Windows) to my Unix server (HP-UX). I don't have unzip cmd available in my curent Unix version Please let me know any cmd in UNIX (other than unzip) using which I can unzip this .ZIP file . Please elaborate on the commands aval and... (5 Replies)
Discussion started by: sureshg_sampat
5 Replies

9. HP-UX

How to Unzip a .ZIP file in Unix without using unzip cmd..?????

Hi All I have ftped a .ZIP file (zipped using WinZip in Windows) to my Unix server (HP-UX). I don't have unzip cmd available in my curent Unix version Please let me know any cmd in UNIX (other than unzip) using which I can unzip this .ZIP file . Please elaborate on the commands aval and... (5 Replies)
Discussion started by: sureshg_sampat
5 Replies

10. UNIX for Advanced & Expert Users

How to unzip a .zip file when

there is no unzip package present. (2 Replies)
Discussion started by: yogesh_powar
2 Replies
Login or Register to Ask a Question