File Test Operators
Author Archives: deathadder
Bash Pitfalls
Very helpful site: http://mywiki.wooledge.org/BashPitfalls
Splitting Strings in bash
Say you’ve got a pipe ‘|’ separated string; to get each element of it you can use awk. myString=”a|b|c|d” firstElem=$(echo “$myString” | awk ‘{split($0,temp,”|”); print temp[1]}’) firstElem would then contain “a”. Or by using tr: myString=”a|b|c|d” myArray=( $(echo $myString | tr “|” ” “) ) echo ${myArray[0]} # prints a
Remove Windows EOL characters ^M
If you’ve copied/edited a script from a Windows machine you may get a “bad interrupter” error due to Windows EOL characters seen as ^M, sometimes, in vi. To remove them you can use sed like so: $ sed ‘s/^M//g’ Win_File > Unix_File To get ^M you’ll need to enter ‘Ctrl-V Ctrl-M’. You can do the [...]
Configure PAN to use SSL
Pan, a GTK news reader does not support SSL connects itself, which means if you want to connect to a news server using SSL you will have to setup a SSL tunnel. To do this you will need to install stunnel, I’m going to assume you have already installed stunnel and wish to know how [...]
Uninstalling Software
Here I will explain the ways to uninstall software you installed via source code, Debian and Red Hat packages. To remove software you’ll need to run the commands below as the root user. Source code (tar.gz / tar.bz2) Debian Packages (debs) Red Hat Packages (rpms) Source code To uninstall from source it is easiest to [...]
Installing Software
There are a number of ways to install software within Linux using the command line, you can compile the source code yourself, or use a precompiled binary. Here I plan on explaining how to install software using the main methods, these are: Source code (tar.gz / tar.bz2) Debian Packages (debs) Red Hat Packages (rpms) However [...]