Showing posts with label shell. Show all posts
Showing posts with label shell. Show all posts

Understanding even the most complex shell commands

https://yalneb.blogspot.com/2019/06/explainshell.html

The website explainshell.com has a very simple goal: enter any shell command and it will explain the string bit by bit. It is extremely useful if you are starting out with Linux and still don't know your way around the terminal, but it is still quite handy for more advance users.

Take the following shell command: echo "YALNEB.BLOGSPOT.COM" | sed 's/LO.*T/y/g;s/COM/Andres/g' | tr '.' ' '. It is quite ugly to look at, but all it does is print: YALNEB By Andres. How? Well, it's really simple! Take a look at the explanation and you will see how ingenuous this script actually is ;)

Fancy bash prompt with colors

Read full article: Fancy bash prompt

I got bored of the normal bash promt a long time ago, which lead me to configure my .bashrc to betther highlight terminal inputs. Still, I used to see some terminal on the net with a very fancy looking bash promt that I found really appealing. After some googling I decided to give it a go and try to generate my own. All it takes is a fancy triangle character to create the colored overlaps, shown in the above figure, and some tweaking. All in all, the end result speaks for itself.

Check out my implementation after the break, and leave a comment if you like it or want to make some suggestions to further improve it!

Update: a new and easy to install version can be found here.

rsync: copy files the intelligent way

http://yalneb.blogspot.com.es/2017/05/rsync.html

You probably heard about last Friday's massive cyber attack that affected millions of outdated machines that still run Windows XP, but also newer version. Luckily the pandemic got halted almost by sheer luck (read more at hackaday).

Anyway, it could have affected any of us (maybe dual-boot?), which alerted me of the fact that I had not backed up my files for quite some time now. This gave me two options. Either plug in my external backup HDD and copy everything with my file browser (overwriting old files), or do it the intelligent way: an incremental update to my backup with rsync to only copy modified files.

Run Linux shell commands sequentially

http://yalneb.blogspot.com/2017/02/run-linux-shell-commands-sequentially.html

It is possible to concatenate Linux shell commands using either && or || or ;.
  • && Run second command if the exit status of the first command is successful.
  • || Run second command if the exit status of the first command is not successful.
  • ; Run second command no matter what the exit status of the previous command.
As shown in the figure above, this can become very handy to concatenate Linux commands depending on their exit status, specially if the first command is rather slow and you do not want to wait for it to finish. For example, I use && all the time to compile some source code from the terminal and run it as soon as it finishes.

Note that you can run an arbitrary long number of commands sequentially, so go out and play while you leave your workstation finish a batch of commands.