Tag Archives: files

How to Unzip Multiple Files from Linux / Unix single Command Line

bash-3.2# ls *.zip
118666-47.zip  120830-06.zip  138852-01.zip  142394-01.zip  147217-02.zip
118777-16.zip  120849-04.zip  139520-02.zip  142933-05.zip  148027-03.zip
119081-25.zip  124204-04.zip  142240-01.zip  143506-06.zip
119963-24.zip  126425-01.zip  142251-02.zip  146470-08.zip

Problem :

bash-3.2# unzip *.zip
Archive:  118666-47.zip
caution: filename not matched:  118777-16.zip
caution: filename not matched:  119081-25.zip
caution: filename not matched:  119963-24.zip
caution: filename not matched:  120830-06.zip
caution: filename not matched:  120849-04.zip
caution: filename not matched:  124204-04.zip
caution: filename not matched:  126425-01.zip
caution: filename not matched:  138852-01.zip
caution: filename not matched:  139520-02.zip
caution: filename not matched:  142240-01.zip
caution: filename not matched:  142251-02.zip
caution: filename not matched:  142394-01.zip
caution: filename not matched:  142933-05.zip
caution: filename not matched:  143506-06.zip
caution: filename not matched:  146470-08.zip
caution: filename not matched:  147217-02.zip
caution: filename not matched:  148027-03.zip

Solution :

Use single quotes [ ‘  ‘ ]
bash-3.2# unzip ‘*.zip’
Archive:  146470-08.zip
inflating: 146470-08/LEGAL_LICENSE.TXT
inflating: 146470-08/prepatch
inflating: 146470-08/SUNWcsu/reloc/usr/share/lib/zoneinfo/EST
inflating: 146470-08/SUNWcsu/reloc/usr/share/lib/zoneinfo/tab/zone_sun.tab
inflating: 146470-08/SUNWcsu/reloc/usr/share/lib/zoneinfo/tab/country.tab
inflating: 146470-08/SUNWcsu/reloc/usr/share/lib/zoneinfo/Australia/Broken_Hill
inflating: 146470-08/SUNWcsu/reloc/usr/share/lib/zoneinfo/Australia/Eucla
inflating: 146470-08/SUNWcsu/reloc/usr/share/lib/zoneinfo/Australia/Melbourne
inflating: 146470-08/SUNWcsu/reloc/usr/share/lib/zoneinfo/Australia/Sydney
inflating: 146470-08/SUNWcsu/reloc/usr/share/lib/zoneinfo/Australia/Adelaide
inflating: 146470-08/SUNWcsu/reloc/usr/share/lib/zoneinfo/Australia/Perth
inflating: 146470-08/SUNWcsu/reloc/usr/share/lib/zoneinfo/Australia/Lord_Howe
inflating: 146470-08/SUNWcsu/reloc/usr/share/lib/zoneinfo/Australia/Hobart
inflating: 146470-08/SUNWcsu/reloc/usr/share/lib/zoneinfo/Australia/Currie

Delete Files Older Than x Days on Linux / Unix

The find utility on linux allows you to pass in a bunch of interesting arguments, including one to execute another command on each file. We’ll use this in order to figure out what files are older than a certain number of days, and then use the rm command to delete them.

Command Syntax

find /path/to/files* -mtime +5 -exec rm {} ;

Note that there are spaces between rm, {}, and ;


  • The first argument is the path to the files. This can be a path, a directory, or a wildcard as in the example above. I would recommend using the full path, and make sure that you run the command without the exec rm to make sure you are getting the right results.
  • The second argument, -mtime, is used to specify the number of days old that the file is. If you enter +5, it will find files older than 5 days.
  • The third argument, -exec, allows you to pass in a command such as rm. The {} ; at the end is required to end the command.

Find and remove Files in Unix older than the specified number of days

For finding the files older than 31 days

find . -name “filename.ext” -mtime +no_of_days -exec ls -ltr {} ; e.g   find . -name “*req” -mtime +31 -exec ls -ltr {} ;

Verify the timestamp of all the files.They must be older than 5 weeks For Deleting files older that 31 days :

find . -name “*req” -mtime +31 -exec rm {} ;

Verify after execution of the above.

Execute:  find . -name “*req” -mtime +31 -exec ls -ltr {} ;

Unix Backup Key Files !!

  1. Kernel This should be the first file backed up. If it gets deleted you can restore it back. This file is often named /kernel, /unix, or /vmunix.

  2. Password File Having a backup of the password file is a good idea, in case the system password file gets compromised. This is the file referred to as /etc/passwd.
  3. Group File Back this up for similar reasons as you do a password file. This file is /etc/group.
  4. Host Table Make an extra copy of the host table, in case the file is corrupted or entries are removed and then needed in the future. This file is named /etc/hosts.
  5. Filesystem Table This is for recovery of the filesystem configurations. This file is often called /etc/fstab or /etc/vfstab.
  6. Sendmail Config Files If anyone works with sendmail, back these up for sure. If mail breaks, the quickest recovery is to restore from the backed up config files. These would be /usr/lib/sendmail.cf, /usr/lib/sendmail.fc, and /usr/lib/sendmail.mc.
  7. Inetd Configs This file has been known to get misconfigured and is a target for hackers. This is the file /etc/inetd.conf.
  8. TTY settings If you have any specialized devices attached, these should be backed up. These settings are typically found in /etc/inittab, /etc/ttytab, and /etc/ttys.
  9. Start Up Scripts Any special scripts that get started at boot time should be kept in another area. These files would usually reside in the /etc/init.d or /etc/rc#.d directories.