unzip a file then further check contents inside it


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting unzip a file then further check contents inside it
# 1  
Old 11-05-2011
unzip a file then further check contents inside it

Dear all
I need to unzip a file then further it has many folders to perform tak inside each folder.
What Task I need to perform I'm able to do it but once I unzip a folder then I'm not able to do cd folder/ into it. I have written following code for it
Code:
for i in $( ls | grep Run_20111016 )
do
unzip $i
x=$( cat $i)

cd $x/  // now when I'm doing this then it do cd  /Run_20111016.zip but folder // //is //created via name Run_20111016 can you please help with this
cd  EventType_10008/4197487816/
for i in $( ls  | grep Report_25)
do
 unzip $i
grep 919536868475 *
rm *.csv

done
cd ../../../
rm -r test
#rm t.txt
done


Last edited by Scott; 11-05-2011 at 01:25 PM.. Reason: Please use code tags
# 2  
Old 11-05-2011
Instead of x=$( cat $i), try x=$(echo ${i%.*})

--ahamed

---------- Post updated at 08:55 AM ---------- Previous update was at 08:51 AM ----------

And you can refine the code by replacing for i in $( ls | grep Run_20111016 ) with for i in *Run_20111016*

--ahamed
This User Gave Thanks to ahamed101 For This Post:
# 3  
Old 11-05-2011
thanks a lot i'm able to achieve results
thanks for useful information
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

To check for a number inside the file in UNIX

Hi Gurus I am a newbie to Unix programming and I am having a difficulty in finding out a number which is present in a file and storing it in a variable so that i can use it in my shell script. The content of the file "count" is: Count of the files=11 I need to just store the value 11 in... (8 Replies)
Discussion started by: vikramgk9
8 Replies

3. Shell Programming and Scripting

Linux Shell Script to check for string inside a file?

This is what I have so far grep -lir "some text" * I need to check all files on the system for this text, if the text is found I need to change the file permissions so only ROOT has read and write access. How can this be done? (3 Replies)
Discussion started by: mapleleafs89
3 Replies

4. Shell Programming and Scripting

Help in searching a particular string in a file name (not inside the file contents)

Dear Unix Gurus, I am new to shell scripting and in the process of learing. I am trying to find whether a file name has today's date in MMDDYYYY format. I am using the following code and it doesn't seem like working. #!/usr/bin/ksh today=$(date '+%m%d%Y') echo today: $today file=`find... (4 Replies)
Discussion started by: shankar1dada
4 Replies

5. Shell Programming and Scripting

How to grep the contents inside a tar file

Hi All I have searched the possibility of this options everywhere but am unable to find it in any forum. I have a tar file inside which there are n number of files and i dont know them. I need to grep a word inside the tar file and need to know in which file the word resides. > cat a... (2 Replies)
Discussion started by: Whiteboard
2 Replies

6. Shell Programming and Scripting

Script to check a file and replace some of the contents

Hi I have a file that looks like this: Line 0 animal elephant Line 1 animal elephant Line 2 animal elephant Line 3 animal elephant What i am aiming to do is with a script and an input value of... (6 Replies)
Discussion started by: tara
6 Replies

7. 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

8. Shell Programming and Scripting

script to check for a condition inside a file

Hi I am writing a script file which sends the log files along with their size in a folder named log to a file called temp.log using the following cmd: ls -st 190_GSTV_HUX_003QISCGSK026** >> /home/user/temp.log the temp.log looks like this: 16 190_GSTV_HUX_003QISCGSK026_message070321.log ... (11 Replies)
Discussion started by: kiran1112
11 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. Shell Programming and Scripting

check if exists a .ZIP file and unzip it using ftp

hi this is my question i have my script what have to verify the existence of a .ZIP file in a extern server (using ftp). if there are .ZIP files, the idea is what the script "unzip" them in the specified folder. THE PROBLEM IS what the script doen´t unzip the .ZIP files, and besides, delete... (1 Reply)
Discussion started by: DebianJ
1 Replies
Login or Register to Ask a Question