i have a requirement, where i have a directory with 1.csv,2.csv,3.csv...
I'm using tar to archive the file
tar -cvf file1.tar" *.csv
and using gzip to zip the files
gzip file.tar
Now the problem what i have is since the size of the zipped tar file is more than 25MB and there is restriction of the attachment size.. i cannot mail it as an attachment to the email
So im looking for a sh file which will tar.gz files to the size of 25 mb and if it's more than 25mb create an other tar.gz file with rest of file and so on..
i don't want to split and unsplit the tar. is there anything which can be done on this?
What about using the zip -s option to compress your tar file into 25mb files.
zip -s 25m my_archive.zip my_archive.tar
You might want to try bzip2 compression instead of gzip. It is a slower, but generally more efficient compression algorithm.
Command line would become:
tar -cvjf file1.tar.bz2 *.csv
You would then extract with the following command:
tar -xjvf file1.tar.bz2
Hard to tell if it will be enough to get under 25 MB, though.
Ascertain what compression factor you're getting from gzip.
Tar only enough of your CSV files to produce a zipped archive smaller than 25MB
Repeat as necessary.
Related
My source folders are on an external hard drive, but I want my thumbnails local. The following works, but it puts all the extracted files in the same folder as the source files, which requires another step to collect them and move them to a folder on my local machine.
exiftool -b -ThumbnailImage -w _thumb.jpg -ext CR2 -r source_folder_path\ > _extraction_results.txt
Is there any way to write them to a different folder in the same call to ExifTool?
Thanks!
Add the directory path to name given in the -w (textout) option (see examples at that link).
Example:
exiftool -b -ThumbnailImage -w /path/to/thumbdir/%f_thumb.jpg -ext CR2 -r source_folder_path\ > _extraction_results.txt
I'm downloading so many images that their links are inside a file with the command:
wget -i file.txt
I suspect many of the files might have the same names. So I'm afraid they will be overwritten. is there anyway to make wget set sequential names to the file or handle similar names in any other way?
For wget 1.19.1, what you're looking for is the default behavior. Files that have the same names will be numbered when a matching file is found.
Assuming that file.txt looks like:
http://www.apple.com
http://www.apple.com
http://www.apple.com
http://www.apple.com
The output of wget -i file.txt will be four files, named:
index.html
index.html.1
index.html.2
index.html.3
how to undo gzip command in centos?
sudo gzip -r plugins
if I try sudo gunzip -r plugins it give me an error not in gzip format
what I want to do is zip the directory.
tar -zcvf archive.tar.gz directory/
check this answers https://unix.stackexchange.com/a/93158 https://askubuntu.com/a/553197 & https://www.centos.org/docs/2/rhl-gsg-en-7.2/s1-zip-tar.html
sudo find . -name "*.gz" -exec gunzip {} \;
I think you have two questions
How do I undo what I did?
How do I zip a directory
Have you even looked at man gzip or gzip --help?
Answers
find plugins -type f -name "*gz" | xargs gunzip
tar -zcvf plugins.tar.gz plugins
2b. I suspect that your level of linux experience is low so you'd probably be more comfortable using zip. (Remember to do a zip --help or man zip before coming for more advice.)
Explanation. gzip only zips up one file. If you want to do a bunch of files, you have to smush them up into one file first (using tar) and then compress that using gzip.
What you did was recursively gzip up each individual file in plugins/.
I need to free up some disk space on my web server and would like to ask if running the command below would break anything?
My server is running centos 6 with cpanel/whm.
$ find / -type f -name "*.tar.gz" -exec rm -i {} \;
Any help or advice will be greatly appreciated.
Thanks.
Well, you'll lose logs if they are already compressed, or uploaded files if any. By default there shouldn't be any of those files on installed system. Personally I think this is wrong to just jettison what you can instead of trying to find the cause.
You can try finding what's occupying space by running:
du -hs / # shows how much root directory occupies
Compare that to the output of:
df -h # shows used space on disks
If the number didn't match by a far - you probably have unclosed deleted files and a simple reboot will reclaim this space for you.
If not you can proceed by recursively doing:
cd <dir>; du -hs * # enter directory and calculate size of its contents
You can do that starting from / and proceeding to the biggest dir. After all you'll find your source of free space. :)
PS: CentOS doesn't compress logs by default. You will not detect those logs by searching for archived files, but they can be huge. Compressing them is an easy way to get some space:
Turn on compression in /etc/logrotate.conf:
compress
Compress already rotated logs with:
cd /var/log; find . -type f | grep '.*-[0-9]\+$' | xargs -n1 gzip -9
I am wondering, i like 7z compression but how do i compress data only? i dont want a file in the archive with file info. Just raw data, how can i do this? it would also be nice if i can remove headers too but that isnt necessary.
From man 7z:
-si Read data from StdIn (eg: tar cf - directory | 7z a -si directory.tar.7z)