Categories
terminal

Show recently installed packages

There are many different ways to get a list of all recently (or not so recently) installed packages. This can be useful when troubleshooting a recent update that potentially broke your application and/or infrastructure. The commands vary according to the Linux package manager used in your distro. This will generally give you a long list of packages, so it’s a good idea to pipe it to ‘less’. Once in ‘less’, you can use ‘ctrl + d’ to go down 1 page, and ‘ctrl + u’ to go up 1 page, and ‘q’ to quit.

RPM based (Fedora, CentOS, RHEL…):

$ rpm -qa --last | less

If you only want the last 10 updated packages, you can pipe it to head:

$ rpm -qa --last | head

To show all packages installed via rpm:

$ rpm -qa
Categories
terminal

Batch renaming files in the terminal

Renaming a few files, one at a time should not be very time consuming. But if a task requires hundreds, or sometimes thousands of files, there is a simple way to do it as well. You can rename multiple files simultaneously (batch) with using just the bash, in a single line. First, do a ‘dry-run’ with ‘echo’ to make sure this is the result you want. Here are the steps to execute a terminal batch renaming with ease:

To replace the file extension from ‘.config’ to ‘.json’:

$ for f in *.json; do echo "$f" "${f%.json}.config"; done
apple-develop.json apple-develop.config
banana-develop.json banana-develop.config
jackfruit-develop.json jackfruit-develop.config
orange-develop.json orange-develop.config

Then, replace ‘echo’ with ‘mv –‘ to actually rename the files:

$ for f in *.json; do mv -- "$f" "${f%.json}.config"; done
$ ls
apple-develop.config   jackfruit-develop.config
banana-develop.config  orange-develop.config

To replace a prefix ‘develop’ with ‘test’:

$ for f in *.config; do mv -- "$f" "test${f#develop}"; done
$ ls
test-apple.config   test-jackfruit.config
test-banana.config  test-orange.config

To replace the suffix ‘develop’ with ‘test’ (this one actually works with any occurrence of ‘develop’ to ‘test’):

$ for f in *.config; do mv -- "$f" "${f//develop/test}"; done
$ ls
apple-test.config  banana-test.config  jackfruit-test.config  orange-test.config

Now you have successfully finished a terminal batch renaming.

https://stackoverflow.com/questions/5394112/how-can-i-batch-rename-files-using-the-terminal