date int64 1,220B 1,719B | question_description stringlengths 28 29.9k | accepted_answer stringlengths 12 26.4k | question_title stringlengths 14 159 |
|---|---|---|---|
1,308,650,780,000 |
I tried this command to compress all the css files in all subdirectories.
find . -iname "*.css*" -exec gzip -c '{}' > '{}'.gz \;
But it only creates a {}.gz file. I ended up using this:
find . -iname "*.css" -exec sh -c "gzip -c '{}' > '{}'.gz" \;
which works well.
The question is why the first one didn't work a... |
It's all about when and by which shell the command gets interpreted. In the first, your command line shell interprets the >, making a local file before find even starts. In the second, the subshell does, after find replaces the {}, so it works as expected.
| Find exec - Why {} can't be used as the output file name? [duplicate] |
1,308,650,780,000 |
I want to create a GZIP compressed TAR archive containing the contents of /var/log, but excluding /var/log/messages file.
I tried tar -cvf var/log.tar var/log/ -x *.messages*, but got the error message:
tar: You may not specify more than one `-Acdtrux' or `--test-label' option
Any ideas on how to go about this? I'm ... |
The -x flag (short for --extract) tells tar to unpack an archive. The -c flag (short for --create) tells tar to create an archive. You're passing both flags, which is a contradiction. It looks like you probably want to use the --exclude flag instead of the -x flag, e.g.:
tar -cvf var/log.tar var/log --exclude='*.messa... | Trying to Create a TAR Archive, But Exclude .messages Files |
1,308,650,780,000 |
I'm trying to figure out the number of lines that contain the strings "event" and "type". The files I want to search through are in multiple folders and are zipped. I'm able to get an aggregated count of what I'm looking for, but my goal is to have the count displayed for each file. This is what I'm currently using:
... |
For only two tests, this should be enough:
zgrep -E -c 'event.*type|type.*event' /folder1/{folderA,folderB,folderC}/folder2/folder3/result-2018-05-1*
Testing if a line contains type and event is the same as testing if it contains type followed later by event or event followed later by type. This wouldn't scale well ... | Finding the Count for a String on Multiple Zipped Files in Multiple Directories (non aggregated) |
1,308,650,780,000 |
I'm trying to optimize Nginx server. I've enabled Gzip_Static_Module to serve pre-compressed gzip static files like CSS, JS, HTML.
Nginx Wiki says that the timestamps of the compressed and uncompressed files match. So, I'm trying to touch the files before Gzipping.
I'm trying to touch and generate *.gz for these stati... |
I think you're running into a quoting issue because you've got double quotes contained inside the command you're trying to get su -c ... to execute. You might want to try wrapping the whole thing inside single quotes instead.
$ su -c 'find . -type f -name "*.css" -size +1024b -exec sh -c "touch {} && \
gzip -9v < ... | touch & gzip all HTML, CSS, JS files in a directory recursively |
1,308,650,780,000 |
This question discussed how to remove parentheses from simple uncompressed text files.
The accepted answer suggested the following:
cat in_file | tr -d '()' > out_file
To my observation, however, this answer is not able to produce the desired effect on compressed text files using gzip.
Is there any way to remove pare... |
No, at best you can do it without writing the decompressed file to disk, but you do need to decompress it in order to edit it.
zcat in_file.gz | tr -d '()' | gzip -c >out_file.gz
| How to remove parentheses from a compressed (preferably gzipped) text file |
1,308,650,780,000 |
I have a file called file1.atz. I know that it is gzipped. The uncompressed file extension should be .ats. I have read the man pages and I just want to verify I'm uncompressing this correctly, because the program that's supposed to read this file isn't able to (which could be for other reasons, I'm just trying to isol... |
Yes, but easier would be to decompress it to stdout and then redirect it.
gunzip -c -S atz file1.atz > file1.ats
| How to uncompress a gzip file with a custom extension? |
1,308,650,780,000 |
I have multiple .gz file in a folder and I want to unzip it in other folder through gunzip without deleting parent file. Please help.
|
Do you mean something like gunzip -c folder1/myfile.gz > folder2/myfile?
With the -c option, gunzip keeps the original files unchanged.
If you want to do it for all .gz files in folder1, you could use
cd folder1; for f in *.gz ; do gunzip -c "$f" > ../folder2/"${f%.*}" ; done
| gunzip multiple compressed files to another directory without deleting the .gz files |
1,308,650,780,000 |
I was wondering what the difference is when decompressing using gzip -d and zcat.
Sometimes when I try gzip -d it says unknown suffix -- ignored. However, zcat works perfectly.
|
The zcat equivalent using gzip is gzip -dc, and when used that way, it doesn’t care about the file extension. Both variants decompress their input and output the result to their standard output.
gzip -d on the other hand is intended to decompress a file, storing the uncompressed contents in another file. The output fi... | Difference between gzip -d and zcat |
1,308,650,780,000 |
I'm using an production server for loading large data set to Hadoop to access from Hive table.
We are loading subscribers web browsing data of Telecom Sector. We've large number of .csv.gz file (File sizes around 300-500MB) which is compressed using gzip.
Suppose a file is as below:
Filename: dna_file_01_21090702.cs... |
There is a lot of disk I/O that could be replaced by pipes. The func_create_dat_file takes a list of 50 compressed files, reads each of them and writes the uncompressed data. It then reads each of the 50 uncompressed data files, and writes it out again with the filename prepended. All of this work is done sequentially... | Alternative of too much slow gzip -d command |
1,308,650,780,000 |
To estract a single .Z file from a given folder I use uncompress file.Z in a terminal and it works flawlessy. If, in the same folder, I want to extract all the .Z files I use uncompress "*.Z" or uncompress '*.Z' or uncompress \*.Z. But they all give the same error:
gzip: *.Z: No such file or directory
(There I have us... |
It looks like everything you have tried is escaping the special character * causing it to be interpreted literally instead of as a wildcard.
Try using this instead:
uncompress *.Z
"*.Z"
Double quotes will preserve the literal value of the *
Enclosing characters in double quotes (‘"’) preserves the literal value of ... | Uncompressing *.Z files in a folder returns error |
1,308,650,780,000 |
Background
I was trying to gzip a folder, and all its files, recursively. I tried a command off the top of my head, and it was obviously wrong.
The result is that the folder, and all its subfolders and files, are still in place, but every file is gzipped.
E.g.
#Folder
- filename.php.gz
- file2.txt.gz
#Subfolder
... |
You should be able to use the -d option for that:
gzip -r -d ocloud/ ocloud.zip.gz
| How can I undo an incorrect gzip? |
1,462,966,642,000 |
I have a directory where there are multiple folders, each of folder contains a .gz file.
How can I unzip all of them at once?
My data looks like this
List of folders
A
B
C
D
In every of them there is file as
A
a.out.gz
B
b.out.gz
C
c.out.gz
D
d.out.gz
|
This uses gunzip to unzip all files in a folder and have the ending .out.gz
gunzip */*.out.gz
This will "loop"* through all folders that have a zipped file in them. Let me add an example:
A
a.out.gz
B
b.out.gz
C
c.out.gz
D
d.out.gz
E
e.out
Using the command above, a.out.gz b.out.gz c.out.gz d.out.gz will all get un... | gunzip multiple files |
1,462,966,642,000 |
Let's say I have these series of commands
mysqldump --opt --databases $dbname1 --host=$dbhost1 --user=$dbuser1 --password=$dbpass1
mysqldump --opt --databases $dbname2 --host=$dbhost1 --user=$dbuser1 --password=$dbpass1
mysqldump --opt --databases $dbname3 --host=$dbhost2 --user=$dbuser2 --password=$dbpass2
mysqldump ... |
In your comment to @tink's answer you want seperate files in the .gz files:
mysqldump --opt --databases $dbname1 --host=$dbhost1 --user=$dbuser1 --password=$dbpass1 > '/var/tmp/$dbhost1.$dbname1.sql' ; mysqldump --opt --databases $dbname2 --host=$dbhost1 --user=$dbuser1 --password=$dbpass1 > '/var/tmp/$dbhost1.$dbname... | Chaining mysqldumps commands to output a single gzipped file |
1,462,966,642,000 |
I want to take a huge file data.txt and:
Split it by 256m
Add the first 3 lines of data.txt to each split file
gzip it
data.txt looks like:
aaa
bbb
ccc
<data>
<data>
<data>
...
<few million rows>
<data>
The end result would be that each split file will have the same first 3 lines
aaa
bbb
ccc
The most efficient way... |
You can make the filter more complex:
split -C 256M -d -a 3 --filter '(head -n 3 data.txt; cat) | gzip > $FILE.gz' <(tail -n +4 data.txt) data_
This skips the first three lines of data.txt, and then reintroduces them into every split section.
I’m using -C instead of --bytes to ensure that the split files contain full... | How to split, add text for each split and gzip file |
1,462,966,642,000 |
I have to gzip multiple files in a directory and rename them. I dont want to zip them into a single zip file. i.e.
gzip:
ABCDEPG01_20171120234905_59977
ABCDEPG02_20171120234905_59978
ABCDEPG03_20171120234905_59979
to:
ABCDEFG_DWH_ABCDEPG01_20171120234905_59977.gz
ABCDEFG_DWH_ABCDEPG02_20171120234905_59978.gz
ABCDEFG... |
Are you just adding a prefix? Then something like this could do:
prefix=ABCDEFG_DWH_
for f in ABCDEPG*; do
gzip < "$f" > "$prefix$f.gz" && rm -- "$f"
done
| gzip multiple files and rename them |
1,462,966,642,000 |
I want to compress files individually with the particular pattern.
For example, I have directory as below :
/log/log1
-/1/log2/file.1
-/1/log2/file123
-/1/log2/file2.1
/log/log2
-/2/log2/file4.1
-/2/log2/file345
-/2/log2/file3.1
I want to compress all the files having extension .1 inside /log... |
find + bash solution:
find /log -type f -name "*.1" -exec bash -c 'gzip -nc "$1" > "${1:0:-2}.gz"; rm "$1"' _ {} \;
gzip options:
-n - when compressing, do not save the original file name and time stamp by default
-c - write output on standard output; keep original files unchanged
${1:0:-2} - bash's slicing; get fi... | compress file using /bin/gzip with particular patterns |
1,462,966,642,000 |
How to set compression level here?
nice -n 19 tar -czf $out $in
|
nice won't do anything to the level of compression. It will only affect the scheduling of the process by the kernel. All commands below may be prefixed with nice to run them at a different "nice"-level, it will not influence the level of compression, only the time taken to perform the action (if the system is under he... | set compression level with nice and tar |
1,462,966,642,000 |
I have a file that is gzipped twice:
test.gz.gz
How do I grep something from the file above? I don't want to unzip it.
|
You may also
$ zcat test.gz.gz | zgrep "whatever"
zcat and zgrep works like cat and grep but on compressed data streams.
| Grep from a doubly-gzipped file |
1,462,966,642,000 |
Why isn't there any difference (output filesize) with these command lines?
Gzip stdin
The output files have same filesize even though the compression levels are different
tar ... | gzip -c -1 > ...
tar ... | gzip -c -9 > ...
xz stdin
The output files have same filesize even though the compression levels are differen... |
The gzip compression level does not guarantee that higher compression levels result in smaller output. In fact the BUGS section of my man gzip notes that in some cases it can be the opposite.
For xz (and bzip2), this is even more documented, as according to the manual the numerical level controls the amount of memory ... | compression levels gz and xz |
1,462,966,642,000 |
I'm running a long copy of .gz files from one server to another. At the same time, I'd like to unzip the files already copied. For example, al filenames that start with a through filenames starting with c.
How can I do this?
|
The easiest way to do this is to use your shell. Assuming a relatively modern shell (such as bash), you can do
gunzip [a-c]*gz
| Gunzip in range of files |
1,462,966,642,000 |
I have one doubt with this:
for i in ./*.gz
do
gunzip -c $i | head -8000 | gzip > $(basename $i)
done
I get an "unexpected end of file" error for gzip, and I don't get the 8000 at all, only a few tens of lines. I've checked the integrity of my files and they are fine. Curiously, if I run for individual files:
gunzip ... |
You should write the output to a temporary file and then rename:
for i in ./*.gz
do
gunzip -c "$i" | head -8000 | gzip > "$i.tmp"
mv -f "$i.tmp" $(basename "$i")
done
That your version sometimes works is if you gunzip buffers enough while reading.
| Why I get unexpected end of file in my script when using gzip? |
1,462,966,642,000 |
I have a gz archive but for some reason tar said that the format is incorrect even though I can double click it in mac Finder and extract it normally, and file command shows the same format just like any other tar.gz files
Why is that and how to extract it from the terminal?
$ file archive.gz
archive.gz: gzip compres... |
Your compressed file is probably not a Tar archive.
You can find out the uncompressed filename with gunzip -l archive.gz - that might give you a clue as to the format.
If that doesn't work, then gunzip it, and use file on the uncompressed output.
| Normal gz file not extractable by tar [duplicate] |
1,462,966,642,000 |
I have a simple backup script, which also creates a tar/gzip archive of local data to an external USB device and then copies that archive to a second USB device.
For example:
usb1="/mnt/usbone"
usb2="/mnt/usbtwo"
source="/home/user"
tar cfz ${usb1}/source.tar.gz ${source}
cp -ar ${usb1}/source.tar.gz ${usb2}
This se... |
you can use tee command
usb1="/mnt/usbone"
usb2="/mnt/usbtwo"
source="/home/user"
tar -cz -f - "${source}" | tee "${usb2}/source.tar.gz" > "${usb1}/source.tar.gz"
where
-f - tells tar to use stdout as backup file.
tee "${usb2}/source.tar.gz" will copy stdin to specified file and stdout.
> "${usb1}/source.tar.gz" w... | Archive directory with tar/gz to multiple locations and omit an additional copy |
1,462,966,642,000 |
I created an image from a 256GB HDD using following command:
dd if=/dev/sda bs=4M | pv -s 256G | gzip > /mnt/mydrive/img.gz
later I tried to restore the image to another 512GB HDD on another computer using following command:
gzip -d /mnt/mydrive/img.gz | pv -s 256G | dd of=/dev/sda bs=4M
the 2nd command shows very l... |
Following command is not exactly doing what you are intending to do
gzip -d /mnt/mydrive/img.gz > /dev/sda
The command is decompressing the file /mnt/mydrive/img.gz and creating a file called img which is the ungzipped copy of img.gz. The > /dev/sda is not doing anything useful because nothing is sent to /dev/sda via... | restoring hdd image using gzip throws error no space left on device |
1,462,966,642,000 |
I'm trying to make a script that can tail log files from a remote server to my local directory. tail -F is what I'm using but after piping it with gzip, nothing happens although a local copy of the log file is created.
Update:
The script runs but it can't reach the gzip command since I have to type ctrl+c to end the t... |
tail -f is meant to be interactive, other than timeout you should try tail -100 (100 or whatever) to catch last lines.
main part would be
tail -100 /whatever/sample.log | gzip > /whatever/sample.log.gz
| Writing a Shell script to tail and gzip a log file |
1,462,966,642,000 |
In Unix/Linux is there any max files size limit that a compression utility ( gzip/compress) can compress. I remember years ago it was mentioned in the gzip page that it can compress files up to 4 gb. Actually I need to compress fillies of around 512 GB regularly. I tested few files with compress utility and found hash... |
gzip nowadays can compress files larger than 4 GiB in size, and in fact doesn’t have any limit of its own really (you’ll be limited by the underlying file system). The only limitation with files larger than 4 GiB is that gzip -l, in version 1.11 or older, won’t report their size correctly; see Fastest way of working o... | Compression Utility Max Files Size Limit | Unix/Linux |
1,462,966,642,000 |
How can I gzip and copy files to another folder keeping its directory structure with one command in Linux?
For example, I have:
/dir1
/dir1/file1.fit
/dir1/file2.fit
/dir1/file3.fit
/dir1/dir2/file1.fit
/dir1/dir2/file2.fit
/dir1/dir2/file3.fit
After I use a command (Lets we say I copy /dir1 to /another_dir), I want ... |
Assuming you're in the root folder where are all directories for compression (in your case /), you can use find along with xargs command, e.g.
find dir1/ -name "*.fit" -print0 | xargs -i% -r0 sh -c 'mkdir -vp "$(dirname "/another_dir/%")" && gzip -vc "%" | tee "/another_dir/%".gz > /dev/null && rm -v "%"'
Note: You ... | How to gzip and copy files keeping its directory structure? |
1,462,966,642,000 |
I want to exclude two files from a tar file.. But it doesn't seem to work
cd /var/www/public/api_test
tar -zcvf api_v2.x.tar.gz api --exclude "./api/distributor_test.php" --exclude "./api/library/Distributor_API.php"
|
try (in one line, I fold for readability)
tar -zcvf api_v2.x.tar.gz
--exclude api/distributor_test.php
--exclude api/library/Distributor_API.php api
argument (e.g. api) should be put last
you may use --exclude distributor_test.php (if you only have one file named distributor_test.php )
| exclude files in tar.gz |
1,462,966,642,000 |
Here's what I did:
copied some files from server to my local computer
scp root@remotemachine:/var/log/nginx/* /home/me/logs
deleted the files on the server
The next moment I realized, that I forgot to create the target directory on the local machine (/home/me/logs). Now instead of copied files inside 'logs' I see a ... |
In this case scp will copy each source file to /home/me/logs, overwriting /home/me/logs with the contents of each new file.
The result is that /home/me/logs will be a copy of the last source file in the list. All the other source files are lost.
Oops! Regular cp warns and aborts in this case, at least!
| What happens to my files if I scp-ed to non existing directory |
1,462,966,642,000 |
I have a 17 GB tar.gz file which is a tar.gz version of a directory.
I got the following message after the tar operation.
tar: Error exit delayed from previous errors
Now since it takes a long time to download, I just want to be sure that the file is healthy before downloading it. Is there a way to make sure of th... |
You cannot assume the tar.gz file is healthy but IMHO chances it is are quite good.
A very common root cause of the "Error exit delayed from previous errors" is the fact a file has either its size changed while processed or has disappeared just before. Depending on what kind of files your archive contains, this can b... | How to verify the integrity of a tar.gz file? |
1,462,966,642,000 |
I have a bunch of .gz files I'm checking the integrity after data transfer with gzip -t -v file
the output I'm getting is
gzip: C2_CRRA200017850-1a_H3LJWDSXY_L1_2.fq.gz: extra field of 6 bytes ignored
gzip: C2_CRRA200017850-1a_H3LJWDSXY_L1_2.fq.gz: extra field of 6 bytes ignored
gzip: C2_CRRA200017850-1a_H3LJWDSXY_L1_... |
This is normal and there is nothing wrong with the files. It's just that they are bgzip files and not gzip files. Bgzip has some extra fields that gzip doesn't know about:
The BGZF format written by bgzip is described in the SAM format specification available from http://samtools.github.io/hts-specs/SAMv1.pdf.
It mak... | gzip -t output "gzip: filename.gz: extra field of X bytes ignored" |
1,462,966,642,000 |
A long time ago, before I tried incremental and differential backups, I tried to tar/gzip several similar large (1 GB) directories, but they did not compress any better than tarring and gzipping each directory individually. My guess why it didn't work is this:
tar was likely not going to put duplicate files next to e... |
Yes, your reasoning is correct, as tar doesn't sort files by extensions (which could have helped a lot to achieve higher compression ratios) and gzip is a very old compression algorithm with a relatively modest dictionary, just 32KB.
Please try using xz or p7zip instead.
Here's a compression string which allows me to ... | Why won't tar/gzip compress two similar large directories? |
1,462,966,642,000 |
Bit of a weird one - I've got a honeypot running dionaea, which is a tool that consolidates any binaries that were uploaded to the device in single location (/data/dionaea/binaries).
However, every so often (kind of like logrotate), the /data/dionaea/binaries directory gets gzipped into a file called binaries.tgz.n (... |
You can pipe to tar:
gunzip < /path/to/gz | tar tzf -
(Or with GNU tar, you can just use | tar tz.)
| List contents of a tgz archive inside a gz archive |
1,462,966,642,000 |
I have multiple log files from each day that I need to merge together. Each comes from a different server. The job that puts them there sometimes gets interrupted and files get truncated. In that case the file gets written with a different name next time it runs. So I may end up with a list of log files like:
s... |
I’m guessing you’re using the gzip script version of zcat. That just executes gzip -dc, which can’t be told to ignore errors and stops when it encounters one.
The documented fix for individual corrupted compressed files is to run them through zcat, so you won’t get much help there...
To process your files, you can eit... | Merge possibly truncated gzipped log files |
1,462,966,642,000 |
Given that I:
have a directory that contains over 1000 files
have a gzip'ed tar file that contains a subset of those files (x.tgz)
What is the single command line (if it is possible) that will read the gzip'ed tar file's contents and removes all of the files from the directory that are contained within the tar file?... |
You would need to be at the directory from which the tar file was created, for instance $HOME. Then if you had a tgz of your Documents directory located safely in /backup/Documents.tgz you would do this:
$ for file in $(tar -tzf /backup/Documents.tgz); do \
[[ -f $file ]] && rm $file || echo "$file does not exis... | How to delete files from a directory based on the contents of a gzipped tar file? |
1,462,966,642,000 |
Why does this give such output (both commands are supposed to do the same thing) and how can one make them give identical output?
diff <(cat some_file | gzip -c - | base64) <(gzip -c some_file | base64)
1,2c1,2
< H4sIACSOZFUAA2XNsRHAMAgDwDqZRkIQ8P6L+c5xnIL2m2c5E6BdIQA5cHPTaGTqlI3ki2jSoWrk
< e1Tw0PNSMT4KdPKfJgNiJT++AAA... |
gzip is encoding the filename of the input file into its output. Even with -c option it does this. You can see this with gzip -c some_file | strings|head -1. however, when reading from stdin, gzip does not do that, since it doesn't know the filename. You can tell gzip to omit from output the filename and time-stamp wi... | gzip files with cat and from pipe gives different results |
1,462,966,642,000 |
Whenever I need to decompress a file which was compressed with Gzip, I need to rename the file with a .gz extension , I tried other compression utility like zip, bzip2 and they don't seem to care about extensions. Why is this is the case with Gzip , isn't just checking magic numbers to identify a type of file or by ot... |
As I understand it, the general idea is that you can run
gunzip *
and it will use the file extension as a first filter; as described in the man page:
gunzip takes a list of files on its command line and replaces each file whose name ends with .gz, -gz, .z, -z, or _z
(ignoring case) and which begins with the co... | Why GZIP utility cares about extension? |
1,462,966,642,000 |
Context
I am required to use a poorly designed java application that logs A LOT of information while it is running. Under standard usage, it will create 100s of MB of logs per hour.
I don't need historical logs and it currently seems that the logrotate utility can't keep up with it as it doesn't run frequently enough.... |
As the app already splits out the logs into new files, is it possible to automatically compress newly created files in a directory?
Yes, it is. Just target the newly created file with something that can watch for new files in a directory (like entr)
So you'll create a logrotate config like this (/etc/logrotate.d/new... | Is it possible to automatically zip newly created files in a directory |
1,462,966,642,000 |
under SQL directory we have only the tmp folder (tmp folder usage 59G)
is it possible to compress the folder tmp without to leave the original tmp folder ? , so the compression will work on the original folder
the folder usage:
root@serverE1:/var/backup/SQL # du -sh *
59G tmp
so after compression I will see ... |
There are two problems to solve:
how to remove the files without interfering with your output, and
where to put the output while it is being created.
If you happen to not have any dot-files in /var/backup/SQL, it is simple:
just create your output named with a leading ".",
add to the tar-file using the --remove-fil... | how to compress a folder without to leave the original folder and without to remove the original folder |
1,462,966,642,000 |
I am attempting to create a Custom Action in Thunar (File Manager) that will extract a gzip archive into a subdirectory of the same name (e.g. abc.tar.gz to abc/). I created this command, which works, although it puts single quotes around the file name (e.g. 'abc'/ instead of abc/). I ran the equivalent command manual... |
I would try removing the quotation marks around %n. It appears that thunar puts its own marks there, which is why you have them in the folder name.
Also, when you check thunar's examples, they never put the marks around expanded variables.
| Thunar custom action: Extraction to subdirectories |
1,462,966,642,000 |
I tried to compress a directory using tar -zcvf output.gz input_dir. I suppose I should have used a .tgz extension for compressing.
How do I untar output.gz? I tried both tar zxvf output.gz, which didn't yield anything, and gunzip output.gz, which resulted in a corrupted archive.
Is there a proper way of extracting ou... |
tar -zcvf output.gz input_dir
Wrong!
tar -zcvf output.tar.gz input_dir
or
tar -zcvf output.tgz input_dir
Good.
Then estract with
tar -xvf output.tgz
or
tar -xvf output.tar.gz
You can omit z on modern distro,if doesn't work or using old distro use z switch
| Extract files from a corrupted .gz file |
1,462,966,642,000 |
I have a large tar file but it could not be downloaded completely as the browser crashed when verifying the download. Is it possible to extract some files from this tar?
I am able to view the files using tar -tf abc.tar and this shows the directories and folders
a/
a/b/
a/b/1
a/b/2
However if I use tar -zxvf abc.tar ... |
The archive isn’t compressed, so you need to drop the -z flag:
tar -xvf abc.tar a/b/1
However
Failed to open abc.tar
suggests that the tarball itself is no longer there.
| How to extract specific file from partially downloaded tar? |
1,462,966,642,000 |
Objective: The efficient backup and transfer of ~/dircontaininginnumeraltinyfiles/ to /mnt/server/backups/dir.tgz. My first thought was of course rsync and gzip. But I'm open to other routes as well.
(At the end of the desired backup process, /mnt/server/backups/dir.tgz would be a full backup i.e. containing all of th... |
Using tar -cvzf /mnt/server/backups/dir.tgz ~/localdir/ for the time being. Respectfully stepping away from this thread. Thanks for the input. Best regards to all.
| Rsyncing directory to a backup gzip file |
1,547,153,754,000 |
Recently I've changed logs configuration for letsencrypt, because there was no given one and I have files:
letsencrypt.log
letsencrypt.log.1
letsencrypt.log.10
letsencrypt.log.10.gz
letsencrypt.log.11
letsencrypt.log.11.gz
letsencrypt.log.12
letsencrypt.log.12.gz
letsencrypt.log.13
letsencrypt.log.13.gz
letsencrypt.lo... |
Ok, so I've managed to make proper log rotate:
/var/log/letsencrypt/*.log {
weekly
rotate 9
compress
delaycompress
missingok
create 644 root root
}
So the difference is that I've removed notifempty.
| Logs gzipped and not gzipped |
1,547,153,754,000 |
I am experiencing problems trying to zcat the contents of a particular gzip archive containing SQL text. The problem seems localised to one particular file on one server.
I have copied around 10 gzipped SQL files from our backup server using rsync to a new replication server that I am trying to restore them onto. In a... |
Having re-visited this issue recently, I eventually figured out that in this case the problem was due to the McAffee EPO agent which had been installed on the server by our infrastructure team without my knowledge. This agent was blocking access to particular large files on the system including the one in question.
| Unable to read or unzip certain archives on one specific server |
1,547,153,754,000 |
In Linux Ubuntu about the 'tar' command for these versions:
tar -tzf /path/to/filename.tar.gz # Show the content
tar -xzf /path/to/filename.tar.gz # Extract the content
Observe both commands use the z option, and well, they work as expected.
Through man tar, about the z option, it indicates:
-z, --gzip, --gunzi... |
Archiving and compression are two separate things.
Most archiving programs on Windows (e.g. zip, 7z, rar, and many more) combine the two into one program that does both archiving and compression - so people who are used to using Windows tend to think of them as being just one inseparable thing.
While many of these pro... | Why tar command uses gzip command through 'z' option? |
1,547,153,754,000 |
I need to find files newer than x days, and then turn it into a gzip, but I want to do it using pigz.
For now I'm now doing it the slow way; this works:
find /path/to/src -type f -mtime -90 | xargs tar -zcf archive.tar.gz
But pigz is tremendously faster, so I want to run this gzip using pigz instead. I tried this but... |
With GNU tar on any shell that supports process substitution (e.g. bash, ksh, zsh):
tar cf archive.tar.gz -I pigz --null -T <(find /path/to/src -type f -mtime -90 -print0)
This uses pigz to do the compression, and takes the (NUL-separated) list of files to include in the archive from the output of find ... -print0, ... | Pipe find list of files into xargs gzip and pipe again into pigz |
1,547,153,754,000 |
If I make a .tar.gz via
tar czvf - ./myfiles/ | pigz -9 -p 16 > ./mybackup.tar.gz,
Can I safely unzip an already gzip'd file ./myfiles/an_old_backup.tar.gz within the ./myfiles directory via
gzip -d mybackup.tar.gz
tar -xvf mybackup.tar
cd myfiles
gzip -d an_old_backup.tar.gz
tar -xvf an_old_backup.tar
? And can one ... |
If your question can be rephrased as "is it OK to have compressed
archives within compressed archives?", then the answer is "yes".
This may not be the most convenient (as you note, you will have to run
tar several files to get everything unpacked), and applying
compression to data that has already been compressed may ... | Is it safe to do recursive compression with tar, gzip and pigz? |
1,547,153,754,000 |
I would like to make a ZIP file using zip command. Zip file would contain large number of directories containing large numbers of subdirectories, files etc.
Is there any way to calculate final size of ZIP file, but before doing actual zipping on the disk?
For example: Calculating final ZIP file size to determine if ZI... |
From the zip man page:
Streaming input and output. zip will also accept a single dash ("-") as the zip file name, in which case it will write the zip file to standard output, allowing the output to be piped to another program.
So:
$ zip -r - foo | wc -c
Will tell you the compressed size in bytes of the directory fo... | Linux determine ZIP size without compression |
1,547,153,754,000 |
I had a file (was a text file at first), did xxd -r to it and saved it to tempfile2. Afterwards did file tempfile2 and it wrote:
tempfile2: gzip compressed data, was "data2.bin", from Unix, last modified: Fri Nov 14 10:32:20 2014, max compression
I tried:
gzip -d tempfile2>tempfile3
gzip -d tempfile2.gz > tempfile3
g... |
You don't have a tempfile2.gz you only have a tempfile2.
Decompress by doing
gzip -d < tempfile2 > tempfile3
Normally gzip would expect a .gz file for decompression and so you can do
mv tempfile2 tempfile2.gz
gzip -d tempfile2.gz
which would give you an uncompressed tempfile2. Or you could do
mv tempfile2 tempfile... | have file tempfile2.gz (checked via file command) but gunzip/gzip -d does not work |
1,547,153,754,000 |
I'm looking for a way to create a .tar.gz file from a directory but I have some doubts. I'm know that the command for create the file is:
tar -zcvf /path/to/compressed/file.tar.gz /path/to/compress
And then I will get a file.tar.gz but this keep the path to the original sources. So this is what I'm looking for:
Sho... |
Just cd to the folder from where you want the tarball tress structure to start, and use relative paths!
So for instance:
# Note, one folder above
cd /path/to/compress/..
# Tell tar to compress the relative path
tar -zcvf /path/to/compressed/file.tar.gz compress
When you uncompress it, it will create the compress... | Gzip file but excluding some directories|files and also append current date |
1,547,153,754,000 |
I am trying to use tar to recursively compress all files with the .lammpstrj extension within the directory tree starting at the directory whose path is stored in the variable home. home contains the script containing my tar commands and 57 subdirectories, each containing a pair of sub-subdirectories named Soft_Pushof... |
You're honestly overcomplicating things – use your shell to get a list of matching files, and go through these. And let's get rid of all the anachronistic things there – process substitution is usually done using $(…) instead of … these days (both safer to write and nestable!), seq begin end is superfluous wh... | tar: ./.tar.gz: file changed as we read it | "Flagged" files are unrelated to the file tar is supposed to operate on |
1,547,153,754,000 |
I would like to know how to compress several files according to the pattern using gzip, tar, etc... that is, if I have these files:
server_regTCA.log.2021.02.12
server_regTCA.log.2021.02.13
server_regTCA.log.2021.02.14
server_regTCA.log.2021.02.15
server_regTCA.log.2021.02.16
server_regTCA.log.2021.02.17
server_regTCA... |
You haven't mentioned what shell you're using, and that's what controls expansions from patterns.
If you're using bash you can use a brace expansion:
gzip server_regTCA.log.2021.02.{12..15}
If you're using a simpler shell such as sh that doesn't have brace expansions, you're limited to matching with single character ... | Compress several files according to the pattern |
1,547,153,754,000 |
A tar.gz file belonging to root, can be gunzipped by a user, since it is readable by group and public. However after gunzipping, the tar file owner is user, not root anymore. Is it a feature of the program gunzip? or is there another mechanism?
|
On most modern operating systems, including Linux, there is no operation to delete a file. There is an operation to remove a file from a directory (called "unlink"), but it's an operation on the directory, not the file. So if you can modify a directory, you can remove files from it or add files (new ones, or existing ... | Why gunzipping a 644 file belonging to root is possible by user and gunzipped file belongs to user |
1,547,153,754,000 |
I would like to backup all files older than 90 days and greater plus gzip them. I could execute:
find /path/to/files -type f -mtime 90 -exec gzip "{}" \;
Problem with this command is it includes files 90 days old and not older ones. So it will gzip June's files but not May's. Thanks!
|
-mtime +90 should do the trick.
| Backing up files [duplicate] |
1,547,153,754,000 |
Disclaimer: Yes, finding files in a script with ls is bad, but find can't sort by modification date.
Using ls and xargs with echo everything is fine:
$ ls -t1 ssl-access*.gz | xargs -n 1 echo
ssl-access.log.2.gz
ssl-access.log.3.gz
ssl-access.log.4.gz
[...]
Changing echo to zcat:
$ ls -t1 ssl-access*.gz | xargs -n 1 ... |
I found this problem on my system caused by color ls. In my .bash_profile, I had this:
alias ls="ls --color"
I found the result by sending it to stat, which printed something handy:
$ ls local4.notice-201207* | xargs -n1 -P4 -I{} stat {}
stat: cannot stat `\033[0mlocal4.notice-20120711.gz\033[0m': No such file or dir... | Combination of ls, xargs and zcat leads to duplicate file name suffixes? |
1,547,153,754,000 |
I can recall my professor saying it means "Tar-able Gzip." I'm searching it in Google and couldn't find it. I know what Tar and Gzip are. I also know what a TGZ is, but I want to know the meaning of the acronym. I'm really curious whether it is correct or not.
Thanks!
|
tgz is often used as a file name suffix of tar archives that have been compressed using gzip, possibly by compressing it at creation time using tar -cz.
It is just a contraction of tar.gz, which would be the suffix you would get if you first created a tar archive and then compressed it with gzip.
On filesystems that e... | What does TGZ mean? |
1,547,153,754,000 |
I've issued a command gzip -r project.zip project/* in projects home directory and I've messed things up; every file in project directory and all other subdirectories have .gz extension. How do I undo this operation, i.e., how do I remove .gz extension from script, so I do not need to rename every file by hand?
|
Alternatively, you could go into said directory and use:
$ gunzip *.gz
For future reference, if you want to zip an entire directory, use
tar -zcvf project.tar.gz project/
| Wrong zip command messed up my project directory |
1,547,153,754,000 |
I have to make a bash script that do a gzip of a file if is older than 60 days, and move it in a subdir which name is the beginning of the filename. Here an example of the files I have to work with:
-rw-r--r-- 1 X X 0 2012-10-15 11:19 glux21-x1.csv
-rw-r--r-- 1 X X 0 2012-10-15 11:19 GLUX21-x34.csv
-rw-r--r-- 1 ... |
find . -ctime -60 -maxdepth 1 -type f | while IFS= read x
do
gzip -9 "$x" # compress it
D=${x%%.csv}
D=${D/-*/} # remove suffix and everything after the -
mkdir -p "$D" # create dest sub folder
mv $x.gz "$D" # move it
done
This will process all files you needed, and put them into differ... | bash script to gzip files |
1,547,153,754,000 |
I tried downloading a zipped folder from Arxiv (https://arxiv.org/format/math/0606086 under DVI)
but it downloads as div.gz. I understand that this is the TeX output. I tried TeX and various unzip apps, but none of them worked. I even tried renaming it just in case there was a mistake. Any suggestions? If this is not ... |
The file command can be used to identify file format based on the contents of the file.
I clicked the "download DVI" button in Firefox and got a file named 0606086 with no extension.
$ file 0606086
0606086: TeX DVI file (TeX output 2021.09.21:0203\213)
I then ran dvipdf on it and got a readable PDF document as a resu... | File with div.gz extension (mistake?) |
1,547,153,754,000 |
I am working on a script to backup and gzip a set of MySQL tables, scp/ssh them to a different server and then unpack them
current script is:
#!/bin/bash
DATE=`date +"%d_%b_%Y_%H%M"`
BACKUP_DIR=/mnt/data/backups/saturday/
echo Creating new directory /mnt/data/backups/saturday/fathom_$DATE
sudo mkdir /mnt/data/backup... |
The command tar -zvcpf ...$DATE.tar.gz /mnt/data/backups/saturday/fathom_* writes the gzipped backup to $DATE.tar.gz and outputs the list of files that are backed up.
This file list is then piped into ssh [email protected] 'tar -xzf - .... Obviously, the file list is not in gzipped format, which causes the error.
Solu... | gzip, send to server, ungzip |
1,547,153,754,000 |
I am trying to take a file containing text, named MyFile, and compress it into a file named MyFileComp, within the same directory.
I have tried:
gzip MyFile | touch MyFileComp
gzip MyFile >> MyFileComp
Both commands create MyFileComp, but when I open the file it is empty. When I try to decompress the file, it says un... |
I think you are not compressing it right.
Use -c to send it to stdout and add the ".gz" at the end. Is that the issue?
gzip -c MyFile > MyFileComp.gz
gzip -d MyFileComp.gz
| Compress a file into another file, with Gnu/Linux command line |
1,547,153,754,000 |
The program "zip" has a -R feature which allows one to zip all files with a certain name in a directory tree: zip -r v/s zip -R
For example:
zip -R bigfile "bigfile"
Will zip all of the following:
./bigfile
./a/bigfile
./a/b/bigfile
./a/b/c/bigfile
.......
The -R feature doesn't seem to be in gzip or xz though.... |
Combining find, tar and the compression utilities:
With gzip:
find . -type f -name bigfile | tar cfz bigfile.tgz -T -
or with xz:
find . -type f -name bigfile | tar cfJ bigfile.txz -T -
find searches recursively for all files named bigfile under the current/working directory and the resulting pathnames are supplied ... | How may I emulate the -R feature of "zip", but in gzip and xz? |
1,547,153,754,000 |
I'm trying to run find . -name "binaries.tgz.*.gz" -exec gzip -d -k < {} \; (ultimately I'm trying to run find . -name "binaries.tgz.*.gz" -type f -exec gzip -d -k < {} \; | tar tzf - but I'm trying to figure out why the command before the pipe isn't working first), but I get the following error:
-bash: {}: No such ... |
In your command
find . -name "binaries.tgz.*.gz" -exec gzip -d -k < {} \;
the < {} is interpreted by the shell before running find.
Use
find . -name "binaries.tgz.*.gz" -exec gzip -d -k {} \;
to extract all files and keep the original ones.
You can try
find . -name "binaries.tgz.*.gz" -type f -exec gzip -d -c {} \;... | "-bash: {}: No such file or directory" using find exec [duplicate] |
1,547,153,754,000 |
I use
sudo tar xvzf forwarder.tar -C /opt/
on Linux and this works perfectly then I proceed with a
. /splunk start
to install a forwarder file.
While in AIX, its forwarder is in .gz format and I tried using
gzip -d filename.gz
And it just decompresses the gz file. Tried also using
sudo tar -xvf -C "/directory/path... |
Though we cannot be sure of what your file contains,
as @JeffSchaller suggested, try piping the output of gzip into tar as follows:
gzip -d <filename.gz |
sudo tar -xvf - -C "/directory/path/"
If this doesnt provide your wanted file, then use the file command on the data to see what type it is. Eg: file filename.gz,... | filename.gz installation on AIX |
1,547,153,754,000 |
I have a gzipped file (around 3Kb), and I want its size to be exactly 4000.
To achieve this goal, is it safe to add trailing padding with zeroes? (By safe I mean that the content of the gzipped file can be gunzipped without errors.)
dd if=/dev/zero of=/myfile bs=1 count=4000
dd if=/gzipfile.gz of=/myfile
If this is n... |
From the man page:
CAVEATS
When writing compressed data to a tape, it is generally
necessary to pad the output with zeroes up to a block
boundary. When the data is read and the whole block is
passed to gun‐ zip for decompression, gunzip detects that
there is extra trailing garbage after the compressed data
and... | How to safely enlarge a gzipped file? |
1,547,153,754,000 |
I'm trying to dump a huge database and compress the dump in order to not have to wait hours till it's done.
I dump the database the following way:
pg_dump -Fc -U -v | gzip > db$(date +%d-%m-%y_%H-%M).tar.gz
This leaves me with a compressed tar file.
I know want to unzip it in order to have a .tar file only:
tar -xvf... |
This leaves me with a compressed tar file
No. You're using -Fc, which gives you a "custom" file format specific to pg_dump and pg_restore. That's not a tar, so you're not compressing a tar file with your gzip call.
Furthermore, the pg_dump documentation points out:
Output a custom-format archive suitable for input ... | Unzip compressed dump and import via psql |
1,547,153,754,000 |
I am following a guide to learn terminal commands and have encountered the use of hyphens to refer to stdin in the following command used to find all files named 'file-A' within the directory playground. I understand it's usage to refer to the files found by the find command which are of course piped to tar and set to... |
I can't find it in the tar manual. However - is often used by tools as a pseudo-filename referring to stdin or stdout. tar is using if for both. -f - saying output to stdout and --files-from=- saying get a list of file-names from stdin. The in and out are implied, these options expect an output and input respectively.... | What would the value of hyphen actually look like in this instance used to refer to stdin for this archive command? |
1,553,510,077,000 |
I run into an error while extracting a tar file, the created directory are created with the chmod 666 instead of 777. Therefore it will not extract inside this folder.
Here is my command:
$umask 000 && tar -xvzf compress.tgz
tar: dist/assets: Cannot mkdir: Permission denied
tar: dist/assets/favicon.ico: Cannot open: P... |
As you can see from the output of tar tv the permissions in the archive itself are broken. If you have any control over the tool that created this archive I would strongly recommend that you fix it, or report a bug.
I assume you still need to extract the files from the broken archive. Try this:
tar xzvf compress.tgz -... | tar command create directory without 777 permission |
1,553,510,077,000 |
I am having a two linux server set up.
ServerA has /apps/data.
ServerB has mounted on /data ServerAs path /apps/data with NFS.
How load of various operations is handled? by meaning:
Q:
By initiating gzip for example (could be cp as second example) on ServerB the I/O is handled by ServerA or ServerB
How disks perform? ... |
You have a directory shared over NFS from ServerA and mounted by ServerB.
If you perform a file operation in that directory on ServerB, there will be no disk I/O happening on ServerB, but there will be network I/O between the servers, and ServerA will eventually perform the actual disk operations (by instructions from... | Disk performance between servers in NFS directory |
1,553,510,077,000 |
I frequently use the commands like
find . ! -iname "*test*" -o -iname "*foo*" | xargs zgrep -ie first.*last -e last.*first
I use zgrep because it can grep through .gz files, and if the files aren't gzipped it simply uses grep. However I frequently get
gzip: copy.txt.gz: No such file or directory
logs that clutter ... |
You can redirect the command standard error output to the null device.
find . ! -iname "*test*" -o -iname "*foo*" | xargs zgrep -ie first.*last -e last.*first 2>/dev/null
| Mute gzip errors/warnings when using zgrep |
1,553,510,077,000 |
I try to gzip a file abc.log which has size of 111 bytes, but after gzip, the size of the file increased to 125 bytes, why is that? Is it when i perform gzip, it will create header and trailer that has certain size?
Command used:
gzip -5 abc.log
|
Not just gzip, but attempting to compress a file which is already as small as possible can increase the size (because each method for compression has some overhead in the form of header, tables, etc). This is also referred to as negative compression.
Further reading
What's the most that GZIP or DEFLATE can increase ... | Linux Gzip increasing size |
1,553,510,077,000 |
I have a .tar.gz as input and want to extract the first 128 MiB of it and output as a .tar.gz in a single command. I tried:
sudo tar xzOf input.tar.gz | sudo dd of=output bs=1M count=128 iflag=fullblock | sudo tar -cfz final.tar.gz -T -
which is obviously not working. How can I achieve this.
|
Instead of trying to extract the archive’s contents (which can’t work here — there’s no way to track the individual files’ metadata), decompress it, truncate it and recompress it. If you have a version of head capable of this:
gzip -dc input.tar.gz | head -c128M | gzip -c > final.tar.gz
or you can use dd as in your c... | Extract first n bytes from .tar.gz and output as a .tar.gz in a single command |
1,553,510,077,000 |
On Linux Mint 20.2 Cinnamon I would like to create a disk image of my secondary disk drive (SATA) containing Windows 10, not that it matters now, directly gzip'ed using the Parallel gzip = pigz onto NTFS formatted external HDD (compressed on-the-fly).
My problem is inside the resulting compressed file, there is someho... |
I may just have found an answer to this oddity.
As the gzip manual page says:
Bugs: The gzip format represents the input size modulo 2^32, so the --list option reports incorrect uncompressed sizes and compression ratios for uncompressed files 4 GB and larger.
It further states:
To work around this problem, you can ... | 1TB drive compressed shows only 3.8GB, what did I do wrong? |
1,553,510,077,000 |
I want to trim the path of the gunzipped tarball so that some "spurious" leading directories are excluded. Let me explain with an example.
I have the following directory structure, as outputted by the tree command:
tree /tmp/gzip-expt
/tmp/gzip-expt
├── gunzip-dir
├── gzip-dir
└── repo
└── src-tree
├── l... |
They're not spurious, it just stores exactly what it was told to store.
In particular, given the path /tmp/gzip-expt/repo/src-tree, it can't know which parts of the path should be kept, if the files should be stored as /tmp/gzip-expt/repo/src-tree/l1file.txt, or src-tree/l1file.txt or l1file.txt etc. It makes a differ... | Getting rid of spurious directories with tar -xzvf, while gunzipping |
1,553,510,077,000 |
I have extracted a file 'linux' from ubutu installation .iso file.
The command file linux gives me this output.
linux: gzip compressed data, was
"vmlinuz-5.4.0-42-generic.efi.signed", last modified: Sat Jul 11
08:53:21 2020, max compression, from Unix, original size modulo 2^32
30118272
To uncompress it, I tried gzi... |
gunzip (or gzip -d) tries to infer the output filename by removing the "dot suffix" from the input file name. Since filename linux doesn't have a suffix, if doesn't know what to name the output.
If your version of gzip supports the -N option you can try using that to restore the extracted file's original name:
-N -... | can't uncompress a gzip compressed data |
1,553,510,077,000 |
I had 100 images from a Raspberry Pi project and in order to transfer them to another computer, I used the "Compress" interaction after selecting all of the images and using the right click context menu. The resulting file (.gz) has the correct size, but there is only one image inside (and of correct size), which even... |
The problem arises from the misuse of the file format, which is not intended for multiple files, as roaima clarified. The gzip manpage states:
If you wish to create a single archive file with multiple members so
that members can later be extracted independently, use an archiver
such as tar or zip. GNU tar supports th... | Compressing multiple files to .gz misbehaving |
1,553,510,077,000 |
I created the compressed tar file using the below command.
find /app/jboss -not -name "*.err" -not -name "*.log" | cpio -o | gzip >/app/patchbkp/test/REDHAT_jboss-eap-7.2_18-Aug-2020.tar.gz
I got the compressed file here
[user1@myhost test]$ ls -ltr /app/patchbkp/test/REDHAT_jboss-eap-7.2_18-Aug-2020.tar.gz
-rwxrwxr-... |
The first command creates a compressed cpio-format archive with absolute filenames. This means that when you extract the files, they will be placed in those absolute places
Note that cpio -o writes a cpio-format archive, not a tar-format one. You should use cpio -o -H tar for a tar-format file.
Your extract command wi... | How to extract a compressed tar using cpio to a particular directory location |
1,553,510,077,000 |
I am using RHEL. How can I find files in the directory /path/to/directory/ which contain the string SomeText if those files are .gz archives?
|
You can use zgrep just like you would use grep:
zgrep SomeText /path/to/directory/*
Or, to make it recursive (if you have Zutils), including hidden files:
zgrep -R SomeText /path/to/directory/
Or, to make it recursive (without Zutils):
find /path/to/directory/ -type -f -exec zgrep SomeText {} +
| How to find files in the directory “/path/to/directory/” which contains information "SomeText" if they are in archives .gz? |
1,553,510,077,000 |
I want to back up each of the directories in /home, in separate .tar.gz files, to the /backup directory. Here an example. I know how to compress them. But not sure, how to send it in another directory.
/home/ab123456, /home/ertoto, /home/mange
/backup/ab123456.tar.gz, /backup/ertoto.tar.gz, /backup/mange.tar.gz
|
You can loop over the contents of /home
cd /home
for file in */; do tar czf /backup/"$file".tar.gz "$file";done
| gzip multiples directory into archives in another directory |
1,553,510,077,000 |
Based on this page: http://code.google.com/speed/page-speed/docs/payload.html#GzipCompression
I need to enable compression on my website.
|
You should start googling words 'apache compression'. First link in SERP will lead you to http://httpd.apache.org/docs/2.0/mod/mod_deflate.html
| Configure webserver for compression |
1,553,510,077,000 |
I created some pigz (parallel gzip) - home page - compressed archives of my SSD disk drives. (compiled version 2.8)
I called one of them 4TB-SATA-disk--Windows10--2024-Jan-21.img.gz which says the size of the drive and the OS installed on it. Alternatively, the size is of course smaller in TiB which may be comfortabl... |
When I thought about it, I realized that without uncompressing the archive, this likely will not be possible, so I came up with the following:
$ cat 4TB-SATA-disk--Windows10--2024-Jan-21.img.gz | unpigz -p8 | pv >/dev/null
3.64TiB 1:56:53 [ 543MiB/s] [ 543MiB/s] [ <=> ]
While I still... | How to verify size of pigz (parallel gzip) archive contents? [duplicate] |
1,553,510,077,000 |
I have an application that has many thousands of files totaling over 10TB.
I'd need to backup this data somewhere (probably to AWS S3).
I'd like to:
compress data being backed up
save the backup as a single file
For example as a gzipped tarfile.
Because of the size, I cannot create the gzipped tarfile locally becaus... |
This is a basic piping and ssh use case.
$ tar zcf - -C /path/to/your/files . | ssh S3_hostname 'cat > yourfile.tar.gz'
To decompress:
$ ssh S3_hostname 'cat yourfile.tar.gz' | tar zxf - -C /path/to/extract/to
The key here is telling tar that it should write to or read from stdout/stdin instead of a file on the loca... | How to backup many large files to single compressed file on S3 |
1,553,510,077,000 |
I have a script with a while loop that will print a text. I want to save it into files with custom name.
Script:
#!/bin/bash
while true
do
echo "Press [CTRL+C] to stop.."
done
I can run split:
./loopscript.sh | split -dl 10000 --additional-suffix=.txt
Output:
x001.txt
x002.txt
x003.txt
x004.txt
x005.txt
But I ... |
For the custom name (the prefix) you can just add it at the end as argument. For filtering all output files through gzip you can use the --filter=COMMAND option. Also -a3 is optional if you need to define the suffix length to 3 characters (001, 002 etc) . Also note the - (to read stdin) before the output prefix argume... | Split file from a streaming output with custom name and gzip |
1,553,510,077,000 |
I have 2 scripts.
I'm calling my script2 as sh scriptpath/script2.sh & inside script1
which compresses files using a combination of find, xargs and gzip commands on 16 files at a time. It is basically a file watcher script integrated to run the process below after checking if a file is present. (Not cron)
Reference: h... |
xargs -t writes to stderr. Your > /dev/null doesn't affect stderr. So you are writing to the terminal from a background process which usually is a bad idea.
| Another called script not going into background even given & |
1,553,510,077,000 |
I have a directory with thousands of files .gz and I would like to uncompress and save the uncompressed files in a specific directory.
I have tried but I can get it (beginner in this field).
Thanks
|
Try something like:
mkdir destination
cd destination
for g in ../origin/*.gz; do # Each *.gz file in origin...
gzcat $g > ${g##../origin/} # ... gets uncompressed to here
done
With thousands of files, the glob (../origin/*.gz) might choke... and the destination directory might also get very slow.
| unix uncompress multiple gz and save in particular directory |
1,333,655,309,000 |
In Linux I can create a SHA1 password hash using sha1pass mypassword. Is there a similar command line tool which lets me create sha512 hashes? Same question for Bcrypt and PBKDF2.
|
Yes, you're looking for mkpasswd, which (at least on Debian) is part of the whois package. Don't ask why...
anthony@Zia:~$ mkpasswd -m help
Available methods:
des standard 56 bit DES-based crypt(3)
md5 MD5
sha-256 SHA-256
sha-512 SHA-512
Unfortunately, my version at least doesn't do bcrypt. If your C library ... | How to create SHA512 password hashes on command line |
1,333,655,309,000 |
I tried to use sha256sum in High Sierra; I attempted to install it with MacPorts, as:
sudo port install sha256sum
It did not work.
What to do?
|
After investigating a little, I found a ticket in an unrelated software in GitHub sha256sum command is missing in MacOSX , with several solutions:
installing coreutils
sudo port install coreutils
It installs sha256sum at /opt/local/libexec/gnubin/sha256sum
As another possible solution, using openssl:
function sha2... | No sha256sum in MacOS |
1,333,655,309,000 |
sha1sum outputs a hex encoded format of the actual sha. I would like to see a base64 encoded variant. possibly some command that outputs the binary version that I can pipe, like so: echo -n "message" | <some command> | base64 or if it outputs it directly that's fine too.
|
If you have the command line utility from OpenSSL, it can produce a digest in binary form, and it can even translate to base64 (in a separate invocation).
printf %s foo | openssl dgst -binary -sha1 | openssl base64 -A
-sha256, -sha512, etc are also supported.
| How can I get a base64 encoded shaX on the cli? |
1,333,655,309,000 |
I have the md5sum of a file and I don't know where it is on my system. Is there any easy option of find to identify a file based on its md5? Or do I need to develop a small script ?
I'm working on AIX 6 without the GNU tools.
|
Using find:
find /tmp/ -type f -exec md5sum {} + | grep '^file_md5sum_to_match'
If you searching through / then you can exclude /proc and /sys see following find command example :
Also I had done some testing, find take more time and less CPU and RAM where ruby script is taking less time but more CPU and RAM
Test Re... | Find a file when you know its checksum? |
1,333,655,309,000 |
In /etc/shadow file there are encrypted password.
Encrypted password is no longer crypt(3) or md5 "type 1" format. (according to this previous answer)
Now I have a
$6$somesalt$someveryverylongencryptedpasswd
as entry.
I can no longer use
openssl passwd -1 -salt salt hello-world
$1$salt$pJUW3ztI6C1N/anHwD6MB0
to... |
Python:
python -c 'import crypt; print crypt.crypt("password", "$6$saltsalt$")'
(for python 3 and greater it will be print(crypt.crypt(..., ...)))
Perl:
perl -e 'print crypt("password","\$6\$saltsalt\$") . "\n"'
| /etc/shadow : how to generate $6$ 's encrypted password? [duplicate] |
1,333,655,309,000 |
I have four files that I created using an svndump
test.svn
test2.svn
test.svn.gz
test2.svn.gz
now when I run this
md5sum test2.svn test.svn test.svn.gz test2.svn.gz
Here is the output
89fc1d097345b0255825286d9b4d64c3 test2.svn
89fc1d097345b0255825286d9b4d64c3 test.svn
8284ebb8b4f860fbb3e03e63168b9c9e test.svn... |
gzip stores some of the original file's metadata in record header, including the file modification time and filename, if available. See GZIP file format specification.
So it's expected that your two gzip files aren't identical. You can work around this by passing gzip the -n flag, which stops it from including the ori... | Why does the gzip version of files produce a different md5 checksum |
1,333,655,309,000 |
Under the assumption that disk I/O and free RAM is a bottleneck (while CPU time is not the limitation), does a tool exist that can calculate multiple message digests at once?
I am particularly interested in calculating the MD-5 and SHA-256 digests of large files (size in gigabytes), preferably in parallel. I have trie... |
Check out pee ("tee standard input to pipes") from moreutils. This is basically equivalent to Marco's tee command, but a little simpler to type.
$ echo foo | pee md5sum sha256sum
d3b07384d113edec49eaa6238ad5ff00 -
b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c -
$ pee md5sum sha256sum <foo.iso
f10... | Simultaneously calculate multiple digests (md5, sha256)? |
1,333,655,309,000 |
Can we generate a unique id for each PC, something like uuuidgen, but it will never change unless there are hardware changes? I was thinking about merging CPUID and MACADDR and hash them to generate a consistent ID, but I have no idea how to parse them using bash script, what I know is how can I get CPUID from
dmide... |
How about these two:
$ sudo dmidecode -t 4 | grep ID | sed 's/.*ID://;s/ //g'
52060201FBFBEBBF
$ ifconfig | grep eth1 | awk '{print $NF}' | sed 's/://g'
0126c9da2c38
You can then combine and hash them with:
$ echo $(sudo dmidecode -t 4 | grep ID | sed 's/.*ID://;s/ //g') \
$(ifconfig | grep eth1 | awk '{print ... | generate consistent machine unique ID |
1,333,655,309,000 |
Does the hash of a file change if the filename or path or timestamp or permissions change?
$ echo some contents > testfile
$ shasum testfile
3a2be7b07a1a19072bf54c95a8c4a3fe0cdb35d4 testfile
|
Not as far as I can tell after a simple test.
$ echo some contents > testfile
$ shasum testfile
3a2be7b07a1a19072bf54c95a8c4a3fe0cdb35d4 testfile
$ mv testfile newfile
$ shasum newfile
3a2be7b07a1a19072bf54c95a8c4a3fe0cdb35d4 newfile
| Does the hash of a file change if the filename changes? |
1,333,655,309,000 |
I have the working password and can see the hash (/etc/passwd). How do I find the hashing algorithm used to hash the password, without manually trying different algorithms until I find a match?
|
This is documented in crypt(3)’s manpage, which you can find via shadow(5)’s manpage, or passwd(5)’s. Those links are appropriate for modern Linux-based systems; the description there is:
If salt is a character string starting with the characters "$id$"
followed by a string optionally terminated by "$", then... | How to find the hashing algorithm used to hash passwords? |
1,333,655,309,000 |
A careful examination of the /etc/passwd and /etc/shadow files reveal that the passwords stored are hashed using some form of hashing function.
A quick Google search reveals that by default, the passwords are encrypted using DES. If an entry begins with $, then it indicates that some other hashing function was used.
F... |
The full list is in man 5 crypt (web version):
Prefix
Hashing Method
"$y$"
yescrypt
"$gy$"
gost-yescrypt
"$7$"
scrypt
"$2b$"
bcrypt
"$6$"
sha512crypt
"$5$"
sha256crypt
"$sha1"
sha1crypt
"$md5"
SunMD5
"$1$"
md5crypt
"_"
bsdicrypt (BSDI extended DES)
(empty string)
bigcrypt
(empty string)
d... | What methods are used to encrypt passwords in /etc/passwd and /etc/shadow? |
1,333,655,309,000 |
I have a folder with duplicate (by md5sum (md5 on a Mac)) files, and I want to have a cron job scheduled to remove any found.
However, I'm stuck on how to do this. What I have so far:
md5 -r * | sort
Which outputs something like this:
04c5d52b7acdfbecd5f3bdd8a39bf8fb gordondam_en-au11915031300_1366x768.jpg
1e88c68999... |
I'm working on Linux, which means the is the command md5sum which outputs:
> md5sum *
d41d8cd98f00b204e9800998ecf8427e file_1
d41d8cd98f00b204e9800998ecf8427e file_10
d41d8cd98f00b204e9800998ecf8427e file_2
d41d8cd98f00b204e9800998ecf8427e file_3
d41d8cd98f00b204e9800998ecf8427e file_4
d41d8cd98f00b204e9800998ecf... | How to remove duplicate files using bash |
1,333,655,309,000 |
I want to verify a file using md5sum -c file.md5. I can do that by hand, but I don't know how to check the validity in a script.
|
You can use md5sum's return status:
if md5sum -c file.md5; then
# The MD5 sum matched
else
# The MD5 sum didn't match
fi
To make things cleaner, you can add --status to tell md5sum (perhaps GNU's version only) to be silent:
if md5sum --status -c file.md5; then
# The MD5 sum matched
else
# The MD5 sum ... | Use md5sum to verify file in a script |
1,333,655,309,000 |
I am trying to make a script that detects if any of the files in a directory were changed within a 2 seconds interval.
What I have so far is:
#!/bin/bash
for FILE in "${PWD}/*"
do
SUM1="$(md5sum $FILE)"
sleep 2
SUM2="$(md5sum $FILE)"
if [ "$SUM1" = "$SUM2" ];
then
echo "Identical"
else
... |
As others have explained, using inotify is the better solution. I'll just explain why your script fails. First of all, no matter what language you are programming in, whenever you try to debug something, the first rule is "print all the variables":
$ ls
file1 file2 file3
$ echo $PWD
/home/terdon/foo
$ for FILE i... | Bash script detecting change in files from a directory |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.