Bash script gzip files




















There are several ways to run it, depending on the type of script. Each script is a text file that contains the code. The file can then be executed with an interpreter. The same goes for any Python script. In general, a Python script has a file extension of PY. However, there is another way to write a Python script: by embedding Python code in a bash script. In any case, the Python package must be installed in your system. Since it is a popular programming language, all Linux distributions offer pre-built Python binaries directly from the official package servers.

Distributions like Ubuntu, Linux Mint, Pop! Operating system, etc. Open Terminal and create a file called sample-script. Wouldn't this tar the list of files as output by find , rather than the files themselves? I edited my question to make clear that I want to have an archive file for each css,html or js file.

Jos no with the -T option tar processes the input as filenames. I learned something today. You can use globstar. How It Works The key to how this gzip command works is that the shell performs expansions on it to produce a list of each file in the directory hierarchy with a matching name, then passes each of these filenames as arguments to gzip. But this find command, although it works well and won't be slow unless you have many files, runs the gzip command once for each file: find. If you want to exclude them as happens with the globstar -based method detailed above when dotglob is off , you can : find.

What not to do Eliah Kagan Eliah Kagan k 51 51 gold badges silver badges bronze badges. All your matching files will be gzipped. Use --force for overwriting without asking if there is already a gzipped file. Eliah Kagan k 51 51 gold badges silver badges bronze badges. This command substitution based method will frequently break, and quite badly. The problem is that filenames containing spaces or other whitespace will be split and treated as multiple filenames.

Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast Helping communities build their own LTE networks. Podcast Making Agile work for data science.

Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually. Linked Related 2. It appears you may have an XY Problem.

If you just need to extract them, do tar xf filename , and tar is smart enough to automatically determine the format and extract it properly, without you having to tell it what the format of the file is. How exactly are you running it? Try running tar xf filename manually in a terminal, and see if it works.

If not, then your tar is broken, and you should fix it. If it works there, then something is wrong with your script, perhaps what steeldriver said. Also, run your script through ShellCheck. It will find any errors or mistakes that you missed. Show 3 more comments. Active Oldest Votes. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Podcast Helping communities build their own LTE networks.

Podcast Making Agile work for data science. Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually.



0コメント

  • 1000 / 1000