LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 10-26-2012, 05:51 AM   #1
gajananh999
Member
 
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

Code:
#!/bin/bash
FILES=/logs/isac/collation/data/server1/*.7z
for f in $FILES
do
  echo "Processing $f file..."
7za u -o/logs/isac/collation/data/logs1/ "$f"
done
and the file names are like

AEPLWEB1-Server - Copy_H20121026-070000464.log.7z
AEPLWEB1-Server - Copy_H20121026-060000462.log.7z
 
Old 10-26-2012, 06:14 AM   #2
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.6, Centos 5.10
Posts: 16,324

Rep: Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041
Try this http://mywiki.wooledge.org/BashFAQ/001
 
Old 10-26-2012, 06:15 AM   #3
Keith Hedger
Member
 
Registered: Jun 2010
Location: Devon,UK
Distribution: Linux From Scratch, Slackware64,
Posts: 992

Rep: Reputation: 214Reputation: 214Reputation: 214
try:
Code:
while read
do
    7za u -o/logs/isac/collation/data/logs1/ "$REPLY"
done < <(find /logs/isac/collation/data/server1 -iname "*.7z")
 
Old 10-28-2012, 04: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: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950Reputation: 1950
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 04:25 PM.
 
Old 10-29-2012, 10:45 AM   #5
H_TeXMeX_H
Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269
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:

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


Reply

Tags
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 05:28 AM
How can I extract only *.c files from a tar.gz? [KIA]aze Linux - Newbie 7 06-06-2007 05:39 AM
How do I extract files from .daa files under linux? izquierdista Linux - Software 8 04-09-2007 10:37 PM
extract files ust Linux - General 1 08-05-2005 02:16 AM
how to extract .0xx files? provkitir Linux - Software 3 04-19-2005 08:21 PM


All times are GMT -5. The time now is 08:47 AM.

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