Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's 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.
Hello, I am trying to use the command gzip to compress a directory or file list
as argument and compress the file in a file named copia101225, within a directory named ZIPFILES. I want to make sure that if the arguments doesn't exist, the destination directory doesn't exist that it creates it.
I keep failing at compressing the file to copia101225, that is within the directory named ZIPFILES
This is what I have so far:
#! / bin / bash
# Title: Compress a file
# Author: Jose Miguel Colella
# Description: Compress a file
read-p "Enter the file name" ARCHIVO_INPUT
cat test | while read line;
do
echo "Line $ count: $ line"
count = $ [$ count + 1]
done
qzip $ARCHIVO_INPUT > copia101225
markush,
I have a question, when I execute the scriptt (using bash) I get an error: gzip: *.txt: No such file or directory. mv: cannot stat `*.txt.gz': No such file or directory
Does the script that I started with wrong...should I just erase that because what I want to do is given a directory or given a list of files that it zips them in a file named copia, this copia is within a directory named CopiasSeguridad. If any of the arguments inserted don't exist than it created them
I get an error: gzip: *.txt: No such file or directory. mv: cannot stat `*.txt.gz': No such file or directory
This error implies that you have zero files with the extension txt in the directory where you executed the script.
The mv error is simply a knock on from the first error
crts,
your code was helpful yet I got an error: tar: cowardly refusing to create an empty archive
I want it to accept files as arguments for example name arg1 arg2 arg3 arg4
# @ variable contains the string "arg1 arg2 arg3 arg4
an then compresses these files into a file copiaYYMMDD
where YY stands for the year, MM stands for the month, and DD stands for the days.
the file copiaYYMMDD is in a directory named CopiasSeguridad
this is my revised code:
source_files= #@
tar -cvf archive_name.tar $source_files
gzip archive_name.tar
in order to create a tar archive with all files and directories of the current directory, you may use
Code:
tar cf thisdirectory.tar *
Note that you don't need the "-" in front of the options when using tar. Note also, that the gzip command is redundant since you can give it as an option to tar, z for gzip, j vor bzip2
Code:
tar czf thisdirectory.tgz *
will create the archive and compress it with gzip.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.