Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm assuming that by didn't work, you mean it put them in seperate folders. I don't know how to make it all untar into the same folder, but here's a script that will take the files from the seperate folder and put them all into one. Copy and paste the script below into a new text file (Leave out the lines that mark the beginning and the end) in the directory containing the directories your files were untarred into, call it something like move.sh. Then run "chmod u+x <name of script>" and then run "./<name of script>"
---Begin script---
#!/bin/sh
#This script takes files in all subdirectories of the current directory except DEST_DIR and copies them into DEST_DIR
DEST_DIR=all_files #Edit this to point to the folder you want
if [ -d $DEST_DIR ]
then
for file in *
do
if [ -d $file ]
then
if [ $file != $DEST_DIR ]
then
cp -R $file/* $DEST_DIR
fi
fi
done
else
echo "Error: $DEST_DIR does not exist or is not a directory."
echo "To set the destination directory, edit this $0 and set DEST_DIR."
fi
---End script---
thanks man worked like a charm. how the hell did you figure out the command. i tried tar --help and looked through all of the different options with no luck.
I am a bash programmer in my spare time, I use it in the autopackage project.
ls -1 gives a list of each file on a newline, the wildcards (filename globbing) should be obvious, it's the same as in dos.
for varname in[list];
list is a string split using the contents of the IFS special variable, in this case set to a space, so this script will fail if any of the files have a space in the same. The backtick ` operator executes the command inside it and substitutes the output (in this case, the newlines are turned into spaces). Therefore varname is set to each file in turn.
tar xzvf $varname;
extracts the file and "done" indicates the end of the loop.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.