Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 10-26-2012, 04:51 AM   #1
Registered: Aug 2012
Posts: 94

Rep: Reputation: Disabled
Not able to extract files.

Dear All,

i want to extract all the files from one folder and the all fine name contains space in it so it is not able to extract the files

for f in $FILES
  echo "Processing $f file..."
7za u -o/logs/isac/collation/data/logs1/ "$f"
and the file names are like

AEPLWEB1-Server - Copy_H20121026-070000464.log.7z
AEPLWEB1-Server - Copy_H20121026-060000462.log.7z
Old 10-26-2012, 05:14 AM   #2
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,400

Rep: Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395
Try this
Old 10-26-2012, 05:15 AM   #3
Keith Hedger
Senior Member
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Linux From Scratch, Slackware64, Partedmagic
Posts: 2,417

Rep: Reputation: 610Reputation: 610Reputation: 610Reputation: 610Reputation: 610Reputation: 610
while read
    7za u -o/logs/isac/collation/data/logs1/ "$REPLY"
done < <(find /logs/isac/collation/data/server1 -iname "*.7z")
Old 10-28-2012, 03:20 PM   #4
David the H.
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960
chrism01's link is for reading text from a file and operating on the contents. That's not what the OP asked for.

And Keith's is really just a variation of the same technique, only it uses the input from find as the text source, and runs the commands on that list. It will probably work, unless the filenames themselves actually contain newlines, but I see nothing there that simple globbing can't handle already (and I would simply use find's -exec option instead of the loop anyway).

In fact, the OP's code should work just fine as it stands, as far as I can tell, and indeed I would've given pretty much that exact solution. The variable contains a globbing pattern which would expand when the for loop is executed, which it should be able to read correctly and run the sub-commands on.

The only way I can see it failing is if the "$f" variable were not quoted in the subcommands (which would allow word-breaking on the contents), or if "$FILES" was quoted in the outside loop (in which case the content would be seen as a single entry, an unexpanded glob). But the loop as posted doesn't show either of those errors.

If the posted loop is indeed the exact command that was run, then the OP needs to explain in exactly what way it's not working. What errors or output are you actually getting?

Last edited by David the H.; 10-28-2012 at 03:25 PM.
Old 10-29-2012, 09:45 AM   #5
LQ Guru
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287Reputation: 1287
I think the OP is not clear enough for me to provide a solution.

To extract all 7zips in a directory you can let 7zip handle it:

7z x '*.7z'
But, I'm not sure that this is what the OP wants. I'm not sure anyone can be sure until a more concrete example and explanation are provided.


extract, space

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] extract text from files Frakk Programming 17 08-29-2010 04:28 AM
How can I extract only *.c files from a tar.gz? [KIA]aze Linux - Newbie 7 06-06-2007 04:39 AM
How do I extract files from .daa files under linux? izquierdista Linux - Software 8 04-09-2007 09:37 PM
extract files ust Linux - General 1 08-05-2005 01:16 AM
how to extract .0xx files? provkitir Linux - Software 3 04-19-2005 07:21 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:24 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration