Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I've got a bunch of tar and tar.gz files that I would like to unzip. Inside these files, most of them have the same folder structure zipped up inside (although with different files).
If I were to do this manually by right-clicking and selecting "Extract Here," it'd would create a new folder for me with the original file name and dump the files there.
However, when I do this via the command line, the behavior isn't always the same. Sometimes it'd create the desired new folder and other times it wouldn't, causing it to overwrite the extraction of others.
Using the -C option seems to require the folder already existing. How can I mimic the behavior of the manual "Extract Here" in the command line?
Thanks.
You could create a bash function like this;
function untarhere() {
(mkdir -P $1; cd $1; tar xzf $2)
}
and then call it like
untarhere /your/destination/directory /your/tar/file.tar
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm in of need of help.
How do i write a shell script program using Apache Tika as the converter to help me execute .pdf files in one directory and save them in another directory in a different format (json, xml, etc).
A rough example, using JSON:
outdir=../out.d
mkdir -p "$outdir"
for f in *.pdf; do
java -jar tika-app.jar --json "$f" >"$outdir/${f%.pdf}.json" \
|| rm -- "$outdir/${f%.pdf}.json"
done
Obviously, this expects tika-app.jar to be in the current directory; adjust to taste. Similarly, see http://tika.apache.org/1.6/gettingstarted.html for full command-line usage.
To understand the ${f%.pdf} shell syntax, see BashFAQ #73.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
Suppose i have a zip file Old.zip , inside it are fileA and fileB. then i unzip them using: unzip Old.zip -d Old, then i will have a directory named Old, with fileA and fileB inside.
Now the Old.zip is gone, and i want to zip it again, but if i use: zip -r New.zip Old, the New.zip is different from Old.zip: inside it are not two files, but one directory!
Before: After: I want:
Old.zip--+ New.zip--+ New.zip--+
+--fileA +--Old--+ +--fileA
+--fileB +--fileA +--fileB
+--fileB
Any suggestions? How should i use zip command correctly to keep the structure? I will NOT go into Old folder and use zip New.zip fileA fileB and move it to the parent folder since i will write it in shell script.
Try passing the the -j (junk paths) option to zip:
$ zip -rj New.zip Old
That way, the files will be stored without their relative paths.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I am using opensuse for my production environment.
I am login as "test" user and trying to edit a file using "vi" but when i am going to save
that file it shows the following error
**
E138: Can't write viminfo file /home/test/.viminfo
**
Under the "test" user all the files and folder autometically become read-only.
I am trying to change the permission using "root" user but unable to change it.
also I look for temp file like "~/.viminf*" but there nothing like this.
Don't know what to do plaese help....
anyone aware about this problem
Fix your home directory owner and permissions.
sudo chown -R test /home/test
sudo chmod u+rw -R /home/test
And finally check that no old temp files were left behind (e.g. ~/.viminf*) and that you can write in the directory of the .viminfo file.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
i'm trying to move folders to another folders using command line, with overwrite if already exists, but i got error "Is a directory" when using mv..
example:
mv src/test/ dest/
there are many files and folders on src/test/, there are also some files and some folders on dest/
and i want files and folders on dest/ replaced with files and folder from src/test/ if exists, example:
src/test/bla/boo replaces dest/bla/boo
src/test/bla/bla/boo replaces dest/bla/bla/boo
also, everytime one file transfer completed, that one file deleted from src/test/
and overall transfer progress bar would be fine..
what rsync flag should i use to make this happend?
The following command line should achieve what you want:
$ rsync -a --progress --remove-source-files src/test/ dest
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I am working on linux scripts , Assume that the directory is consisting of these following scripts .
ls *.sh
test.sh
MyScripts.sh
My question is , before making any modifications to test.sh script , i want to keep a backup copy of it , so that if anything messes up , i will be not screwed up .
please tell me how can i keep a copy of test.sh in the same directory ?? before making any modifications to the actual file test.sh .
Thank you very much .
Consider using revision control, such as git or Subversion.
You can make a copy before your work too:
cp test.sh test.sh.orig
The usual approach is to
cp test.sh test.sh~
(or test.sh.bck or whatever naming convention). In fact, any decent editor should have an option to do this automatically for you. Vim does it by default (saves a backup name filename~ on modification)
May I heartily suggest a version control solution for this purpose instead?
Good 'starter' options include:
bazaar
mercurial
I personally vouch for git.
I took care to name (D)VCS methods that have ample interoperability options so as to prevent data lockin.
cp test.sh test.sh.`date +"%m_%d_%Y"`
Will make a timestamped backup named test.sh.10_10_2011