ZSH Gem #1: Programmable file renaming

Posted by | Comments (8) | Trackbacks (0)

Welcome to the first article of this year's Advent calendar series. The last Advent calendar was extremely successful so I thought it would be a good idea to continue this.

The topic for the Advent calendar series 2011 is “24 Outstanding ZSH Gems” because the Z Shell is my absolute favorite shell. There's nothing ZSH can't do except the dishes. In my opinion it's much more powerful than any other shell out there. If you are not a ZSH user (yet?), you're still very welcome to enjoy this series as well. Maybe then you'll make the switch. And if not: some features also work similarly in Bash, although they might be not so comfortable there. ;-)

Now let's begin with programmable renaming of files or batch renaming. That sounds very abstract, but let me show you what I mean.

Read more…

Shell trick #1: Numbering lines in text files

Posted by | Comments (0) | Trackbacks (0)

Hi, today I'll present you something new. It is an experiment and I'd be curios whether you like it. I've started a little series of ttyrecs. That means, I've recorded a little tip or trick on the console and uploaded it to PLAYterm so it can be easily played back in the browser. I thought it could be useful to do a little command line gymnastics.

Today I'll show you three ways how you can number lines in text files. We'll do that with cat, nl and vim.

Note: you need JavaScript enabled in order to play the ttyrec.

Read more…

Grep's out of date? Full ACK!

Posted by | Comments (2) | Trackbacks (0)

grep is a handy tool and I use it every day. But sometimes I wish it had some more features. For instance full featured Perl compatible regular expressions (PCRE) since the current implementation is not complete and I think it will never be, automatic recursive search, exclusion of non-text files etc.

Here a tool called ack comes into play. It's a search tool and grep replacement written in Perl, which is able to do all these things. Guess what!

Read more…

Damn Flash Player! Adobe, fix it!

Posted by | Comments (6) | Trackbacks (0)

Adobe Flash has ever been a great source of anger due to many bugs (see here for example) and security vulnerabilities. Anyhow, it has evolved into a widely used technology and many, many websites need it to function correctly (yeah, HTML5 is coming, let's hope it will replace Flash in many places in the near future).

Adobe's bug fixing behavior has never been great and we all know, that Flash for Linux has been permanent beta (or alpha) since we can remember, but enough is enough. There is a severe bug that has now existed for three years, reported by hundreds of users. Adobe closed this report without taking action. Now it has been reported again and I want you to vote for it. Please!

Read more…

#24: The awk basics

Posted by | Comments (2) | Trackbacks (2)

awk is very complex and hard to learn. It is the most difficult task in Linux administrator's lives and drives everyone crazy who tries to learn it. It's written by Gods and used by them, no mortal man can ever learn awk.

In fact…, no! If you know any C-like programming language and regular expressions, awk is absolutely easy and it can make things much easier. It's pretty mighty, but I've never seen any programming language easier than awk (except QBasic).

Read more…

#23: File descriptors

Posted by | Comments (0) | Trackbacks (3)

File descriptors are very essential in programming. When you open a file, you get a token, which identifies the file instance. With this token you refer to the file, write, read or close it. You have about the same on the shell.

Read more…

#22: Processes with high and low priority

Posted by | Comments (3) | Trackbacks (3)

Processes in Linux may run with different priorities so that important processes get more CPU time than less important ones. This priority is called the “nice value” or ”niceness” (NI). The nice value is a number between -20 and +19 with the default value right in the center at 0. The higher this nice value, the “nicer” a process is to others, i.e., the lower its priority.

Read more…

#21: The command line calculator bc

Posted by | Comments (2) | Trackbacks (2)

Performing calculations on the command line is very handy and bc is the tool which does it for you. Also bash can do some calculation stuff, but that's not very intuitive. Bash is built for different things than calculation and so bc is the better choice. It can do much more for you and its syntax is ways easier.

Read more…

#20: Multi-line sed search and replace

Posted by | Comments (6) | Trackbacks (2)

sed is built to process strings (either from STDIN or from a file) line by line. Therefore, you can't search for multiple lines. But there are several ways to work around this. I'll be showing you three ways of performing multi-line replacements.

Read more…

   (Page 4 of 7, totaling 65 entries)
Design and Code Copyright © 2010-2017 Janek Bevendorff Content on this site is published under the terms of the GNU Free Documentation License (GFDL). You may redistribute content only in compliance with these terms. tweetbackcheck