Say you want to print the lines 3 and 7, and all lines from 11 to 15 of a text-file. The following SED one-liner will do for you
sed -n -e ‘3p’ -e ‘5p’ -e ‘11,15p’ textfile.txt
Tags:commandline english linux tech |
Filed on October 31st, 2009 | 1 Comment »
Several people have recently asked me whether or not it is possible to use tuples in their shell script. One example is running a program with a varying set of parameters. Since they often did not find a good solution, they began to formulate their problem in a higher-level scripting language like Ruby. Surprisingly, you [...]
Tags:commandline english linux scripting tech |
Filed on October 2nd, 2009 | 1 Comment »
I like to have the following snippet in my .zshrc (or .bashrc) for convenience
alias lsd=”ls -l|awk ‘/^d/ {print \$9}’”
It displays all subdirectories underneath the current directory. The goodness in this variant is that it gives you the pure names and that you can use it in loops without hassle :
for d in `lsd`; do
mv $d/resultfile.dat [...]
Tags:commandline english linux |
Filed on June 7th, 2009 | No Comments »
This one is for zsh users. As you read this, open your editor at once an add the following line to your .zshrc
setopt extendedglob
This will activate extended globbing and allow you to do even more zsh commandline candy. Here some examples
rm ^important.txt # remove all files in the current dir but important.txt
rm *.log~apache.log # [...]
Tags:commandline english linux tech |
Filed on January 16th, 2009 | No Comments »
Linux workers like you and me often need to move a bunch of files. For example, you want to rename all *.dat files into *.dat_save, or you want to rename all files foo.* into something like bar.*. This, however, is not easy to do using the move command as 1) “mv” only supports a single [...]
Tags:commandline english linux tech |
Filed on November 26th, 2008 | 1 Comment »
Setting up a SVN server on an Ubuntu Vserver running Plesk is smooth like butter. Mmmh, butter… Just for future reference, i’m going to explain it here.
Update: Configuration of basic authentication is included now.
Tags:english linux tech webserver |
Filed on September 16th, 2008 | 5 Comments »
Imagine you set up a new domain on your VServer. After filling in all the data, Plesk creates a directory /var/www/vhosts/FOODOMAIN which is the home directory for the domain’s ftp user as well. This makes sense for FTP access as the directory contains all the important subdirectories such as httpdocs, conf, statistics and more. [...]
Tags:english linux tech webserver |
Filed on September 12th, 2008 | 1 Comment »
I just spent a day getting MoinMoin Wiki to run my vserver. Since I had rather spent this time otherwise and I assume the same holds for you too, I give you a step-by-step tutorial about how to get it running quickly. If you have root access to a vserver running plesk and want [...]
Tags:english linux tech webserver |
Filed on May 1st, 2008 | 1 Comment »
Assume you have a lot of data files where any line in each of those files refers to a common entity. If you don’t want to merge the files by hand you can directly plot them from inside Gnuplot using a pipe:
plot ‘< paste FILE1.dat FILE2.dat’ using 2:4
In the example, both files have two columns [...]
Tags:english linux tech |
Filed on April 23rd, 2008 | No Comments »
Insert the following function into your .bashrc:
# Function that gets a column and row from a tab separated file
tableEntry()
{
sed -n “$1p” $3 | awk ‘{print $’$2′}’
}
You are then able to write
tableEntry 2 5 file.txt
to get the 2nd row and 5th column from any file.
Tags:commandline english linux tech |
Filed on April 18th, 2008 | No Comments »