Unable to unpack files with bunzip2 using while loop


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unable to unpack files with bunzip2 using while loop
# 1  
Old 01-21-2014
Unable to unpack files with bunzip2 using while loop

Hi,

I have a problem with unzipping some file.xml.bz2 files to file.xml using while loop.

all other processing on files is successfull except bunzip2.

here is my piece of code
Code:
while read i
do
bunzip2 $i
done<file.lst;


output
Code:
: No such file or directory.le file1.XML.ftpfail.bz2
: No such file or directory.le file2XML.ftpfail.bz2
: No such file or directory.le file3.XML.ftpfail.bz2
: No such file or directory.le file4.XML.ftpfail.bz2

file.lst contains the names of the file names.

" i " is detecting the file name correctly..

when i use bunzip2 filename as a single command it is working.. but in loop it is failing to detect the file and showing the error as above.

kindly suggest me with the what is the issue.

thank a lot in advance.

Last edited by Franklin52; 01-21-2014 at 03:20 AM.. Reason: Please use code tags
# 2  
Old 01-21-2014
Put double quote and try

Code:
bunzip2 "$i"

How is your file.lst ?
This User Gave Thanks to Akshay Hegde For This Post:
# 3  
Old 01-21-2014
Tried as you said, but results negative.

same error occurred.

file.lst contains only the filenames , line by line.

the files are in -rw-r--r--
file.lst is in 777 format.
# 4  
Old 01-21-2014
set IFS and read line

Code:
IFS=$(echo -en "\n\b")
while read i; do
          bunzip2 "$i"
done <"file.lst"

This User Gave Thanks to Akshay Hegde For This Post:
# 5  
Old 01-21-2014
I got the same error.
Code:
: No such file or directory.le file1.XML.ftpfail.bz2
: No such file or directory.le file2.XML.ftpfail.bz2
: No such file or directory.le file3.XML.ftpfail.bz2
: No such file or directory.le file4.XML.ftpfail.bz2

file.lst contains
Code:
file1.XML.ftpfail.bz2
file2.XML.ftpfail.bz2
file3.XML.ftpfail.bz2
file4.XML.ftpfail.bz2


--------


1 month back we used the same simple code to do work. previously it worked now it is not working.

Last edited by Franklin52; 01-21-2014 at 03:21 AM.. Reason: Please use code tags
# 6  
Old 01-21-2014
There might be carriage-returns can you post o/p of od -c file.lst

Last edited by Akshay Hegde; 01-21-2014 at 02:10 AM..
This User Gave Thanks to Akshay Hegde For This Post:
# 7  
Old 01-21-2014
output of
Code:
od -c file.lst

0000000   Z   H   K   2   6   S   Q   L   5   2   _   T   W   1   0   5
0000020   0   _   _   _   U   P   D   A   T   E   .   X   M   L   .   f
0000040   t   p   f   a   i   l   .   b   z   2  \r  \n   Z   H   K   2
0000060   6   S   Q   L   5   2   _   T   W   1   0   5   1   _   _   _
0000100   U   P   D   A   T   E   .   X   M   L   .   f   t   p   f   a
0000120   i   l   .   b   z   2  \r  \n   Z   H   K   2   6   S   Q   L
0000140   5   2   _   T   W   1   0   5   2   _   _   _   U   P   D   A
0000160   T   E   .   X   M   L   .   f   t   p   f   a   i   l   .   b
0000200   z   2  \r  \n   Z   H   K   2   6   S   Q   L   5   2   _   T
0000220   W   1   0   5   3   _   _   _   U   P   D   A   T   E   .   X
0000240   M   L   .   f   t   p   f   a   i   l   .   b   z   2  \r  \n
0000260


Last edited by Franklin52; 01-21-2014 at 03:22 AM.. Reason: Please use code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unable to loop with ssh

I read a file (iplist.txt) ine-by-line in a loop which has the list of all the server hostnames. With each hostname read; I do ssh and fire multiple commands to gather information about that systemas shown below. #!/bin/bash while IFS='' read -r line || ]; do echo "Text read from file:... (3 Replies)
Discussion started by: mohtashims
3 Replies

2. Shell Programming and Scripting

Unable to set Global variable outside while loop

Below is my code: count=0 if ... ... else ... find * -prune -type d | sort -r -n | while read d; do count=1 if ; then echo "Count1:$count" ... ... break 2; fi ... done ... fi echo "Count2:$count" (9 Replies)
Discussion started by: mohtashims
9 Replies

3. Shell Programming and Scripting

Unable to read the first space of a record in while loop

I have a loop like while read i do echo "$i" . . . done < tms.txt The tms.txt contians data like 2008-02-03 00:00:00 <space>00:00:00 . . . 2010-02-03 10:54:32 (2 Replies)
Discussion started by: machomaddy
2 Replies

4. Shell Programming and Scripting

Unpack individual files from tarball

Say you don't want to unpack the whole thing, just individual files or directories within a .tgz. How to do this? (1 Reply)
Discussion started by: stevensw
1 Replies

5. UNIX for Dummies Questions & Answers

Unable to write to a file within a loop

Hi All, Following is the program that i have written in cygwin. The redirection of the unfound $param1 to error.txt file doesnt work.Can any one help? #!/usr/bin/sh fname=$1 sed 's/ //g' "$fname" > fname1 while read i do echo $i > file1 #param1 is script name ... (1 Reply)
Discussion started by: janardhanamk
1 Replies

6. UNIX for Dummies Questions & Answers

unable to execute while loop

Hi everyone. I wanted to print numbers from 1 to 5 in reverse order. For this I used the following code: #!/bin/bash x=5 while do echo $x x=`expr $x - 1` echo "" done echo "" Well but on compiling the above code, it gives the following error. ... (3 Replies)
Discussion started by: grc
3 Replies

7. Shell Programming and Scripting

Unpack (extract) EAR / JAR files

i have about 30 .EAR files, every ear file have 1 .JAR file. so i need to extract .EAR files then extract .JAR files, and one important thing is that every archive must bee extracted to separate folder. i try with gzip, but when i extract 30 ear files i cant make separate folders.... (1 Reply)
Discussion started by: waso
1 Replies

8. Shell Programming and Scripting

Unable to access variable outside loop

I am unable to access the value set inside the loop from outside loop . Thought of taking this to forum , I had seen other replies also , where a pipe takes the execution to another shell and mentioned thats the reason we do not get the variable outside loop . But I am getting an issue and I am... (1 Reply)
Discussion started by: Armaan_S
1 Replies

9. Red Hat

Method to Unpack cpio files

Hi all, I want to unpack some files .Files and their sizes are: 1. Linux9i_Disk1.cpio -- 500m 2. Linux9i_Disk2.cpio--- 600m 3.Linux9i_Disk3.cpio---- 250m I used cpio -idmv Linux9i_Disk1.cpio command to unpack the files. But Its taking more time to unpack the files.What could be the... (2 Replies)
Discussion started by: William1482
2 Replies

10. Shell Programming and Scripting

unable to access a variable not local to a while loop

I have a while loop like this cat ${filename} | while read fileline do ... done I need to access a variable value $newfile inside this while loop How will i do that?? (6 Replies)
Discussion started by: codeman007
6 Replies
Login or Register to Ask a Question