Category: Bash

Bash tips and tricks

Bash, Linux

Converting Windows text files to Linux

Here is a small overview of how (in)compatible computer operating systems are. Normal text files end the lines as follows: Windows: CR+LF Linux: LF OS X: CR In order to convert line ends here are few tricks I extracted from this page(many thanks to the author): http://kb.iu.edu/data/acux.html dos2unix and unix2dos The utilities dos2unix and unix2dos …

Bash, Linux

resolving addresses starting with /etc/hosts

Introduction: as most Linux administrators know if you type the command, for example: host my.domain.com You get the resolving of the address ONLY through DNS resolving and NOT using the local /etc/hosts file first. Of course if you use the command: ping my.domain.com You get to see the IP which with be tried to be …

Bash, Linux

Change the bash session timeout

Sometimes we need to have a longer bash session timeout value to be able to stay logged-in while nothing is happening on the terminal. Here is the setting you can include in your .bashrc or .profile files: export TMOUT=0 This will set the shell session to have no timeout duration. export TMOUT=345600 This will set …

Bash, MAC OS X

Replacing the missing ‘tac’ command in MAC OS X

After looking into Fink Command and Porticus I could not find the GNU command ‘tac’ for writing bash scripts. So I found these replacements which works well from the following link (Thanks guys :-)) http://trac.osgeo.org/grass/ticket/181 Normal use of tac: …..| tac |……. Replacement Nr. 1 …..| awk ‘{print NR,$0}’ | sort -nr | sed ‘s/^[0-9]* …