Tips tagged sed


10

Tip #878   Random xkcd comic

Displays a random xkcd comic. Requires ImageMagick.

Read more »

10

Tip #210   Calendar with current date

Add the following sed commands to cal to get a calendar with the current date marked:

Read more »

9

Tip #171   Duplicate directory tree

The following command creates in the /usr/project directory, a copy of the current working directory structure:

Read more »

9

Tip #539   Using sed across multiple lines

Sometimes when using sed you find that you need to match across line endings, this can be achieved by getting sed to match the first line and then pulling a second line into the buffer with the N command.

For example, if we have a file: Read more »

8

Tip #384   BBC Weather

Go to [http://www.bbc.co.uk/cgi-perl/weather/search/new_search.pl] and search for your location. Copy the link to the 3 day forecast feed, for example [http://feeds.bbc.co.uk/weather/feeds/rss/5day/world/0105.xml]. Then just put that link into the following command to get a quick command line weather forecast.

Read more »

7

Tip #487   Print part of a file

Print the contents of a file from a given regular expression to another

Read more »

5

Tip #182   MAC address conversion

Convert mac addresses such as 000000abde00 into 00:00:00:ab:de:00

awk '{for(i=10;i>=2;i-=2)$0=substr($0,1,i)":"substr($0,i+1);print}' macaddress_list
sed 's/\(..\)/\1:/g;s/:$//' macaddress_list

// sil at infiltrated.net
Read more »

4

Tip #540   Command examples from shell-fu

The following isn't particularly pretty and should be considered a work in progress, but it's quite fun.

Get examples of ways a command can be used direct from shell-fu by adding the following alias:
Read more »