How to gzip a file to a seperate location in linux ?
Today in this post, we will look how to gzip a particular file and store it to an alternate location.
Lets see how to gzip at current location and an alternate location.
1. GZIP file at same location.
[root@ngelinux01 tmp]# df -h . Filesystem Size Used Avail Use% Mounted on /dev/mapper/rootvg-tmplv 36G 30G 5.0G 82% /tmp [root@ngelinux01 tmp]# gzip ews_newgenp_cache.log [root@ngelinux01 tmp]# [root@ngelinux01 tmp]# ls ews_newgenp* ews_newgenp_cache.log.gz
2. GZIP at an alternate location in case the space is full.
[root@ngelinux01 tmp]# df -h . Filesystem Size Used Avail Use% Mounted on /dev/mapper/rootvg-tmplv 36G 33G 1.5G 96% /tmp [root@ngelinux01 tmp]# gzip ews_newgenp_cache.log gzip: ews_newgenp_cache.log.gz: No space left on device You have mail in /var/mail/root [root@ngelinux01 tmp]# [root@ngelinux01 tmp]# gzip -c ews_newgenp_cache.log > /products/oracle/ews_newgenp_cache.log.gz [root@ngelinux01 tmp]# [root@ngelinux01 tmp]# ls /products/oracle/ews_newgenp_cache.log.gz /products/oracle/ews_newgenp_cache.log.gz
If you have observed above, we have used the “-c” flag with gzip option to zip the file at alternate location.
And using “-c” option, we get an ability to get the binary data in output and redirecting it to an alternate file.