Sponsored Content
Top Forums Shell Programming and Scripting Unable to unpack files with bunzip2 using while loop Post 302884591 by Akshay Hegde on Tuesday 21st of January 2014 02:01:04 AM
Old 01-21-2014
#8 should work, don't know whats going wrong I have tested like this

Code:
[akshay@aix Stuff]$ cat test
file1.XML.ftpfail.bz2
file2.XML.ftpfail.bz2
file3.XML.ftpfail.bz2
file4.XML.ftpfail.bz2

[akshay@aix Stuff]$ od -c test
0000000   f   i   l   e   1   .   X   M   L   .   f   t   p   f   a   i
0000020   l   .   b   z   2  \r  \n   f   i   l   e   2   .   X   M   L
0000040   .   f   t   p   f   a   i   l   .   b   z   2  \r  \n   f   i
0000060   l   e   3   .   X   M   L   .   f   t   p   f   a   i   l   .
0000100   b   z   2  \r  \n   f   i   l   e   4   .   X   M   L   .   f
0000120   t   p   f   a   i   l   .   b   z   2  \r  \n
0000134

[akshay@aix Stuff]$ while IFS= read -r i; do tar -zcvf "${i%$'\r'}" test ; done<"test"
test
test
test
test

[akshay@aix Stuff]$ while IFS= read -r i; do ls "$i" ; done<"test"
: No such file or directory.ftpfail.bz2
: No such file or directory.ftpfail.bz2
: No such file or directory.ftpfail.bz2
: No such file or directory.ftpfail.bz2

[akshay@aix Stuff]$ while IFS= read -r i; do ls "${i%$'\r'}" ; done<"test"
file1.XML.ftpfail.bz2
file2.XML.ftpfail.bz2
file3.XML.ftpfail.bz2
file4.XML.ftpfail.bz2

It's problem with file.lst remove carriage return and use it

You can delete carriage return like this
Code:
$ tr -d '\r' <file.lst >newfile.lst

--edit--

Quote:
how to run shell scripts as I mentioned in the previous post (123.sh). when I run simply as 123.sh and only one command in it, it is working fine.
You can run like this
Code:
$ chmod +x scriptname
$ ./scriptname

Code:
$ sh scriptname

Code:
$ bash scriptname

Code:
$ ksh scriptname

depending on what shell you are using

Kindly use codetags

Last edited by Akshay Hegde; 01-21-2014 at 03:09 AM..
This User Gave Thanks to Akshay Hegde For This Post:
 

10 More Discussions You Might Find Interesting

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

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

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

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

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

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

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

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

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

10. 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
All times are GMT -4. The time now is 01:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy