Ad

Showing posts with label Software - Unix. Show all posts
Showing posts with label Software - Unix. Show all posts

Wednesday, July 9, 2014

SED unix utility explained

SED is a great unix utility that enables you to manipulate the contents of a file with simple regular expressions. Say for instance if you wanted to remove the first line in a file:

sed -i '1d' /filepath/hello.txt

The above command specified to insert the text into the file i.e. modify the file specified after the command.
The '1d' tells sed to delete the first line from the file.

You can also replace text in files e.g:

sed -i 's/text your looking for/text you want to replace it with/' /filepath/hello.txt

The above statement will find the text: "text your looking for" and replace it with "text you want to replace it with" the 's' in the beginning stands for pattern space. The syntax explained:

s/regex/replacement/

Have fun with it!

Monday, November 8, 2010

SSH Tunneling

SSH tunneling simply redirects all traffic from a remote port of a remote host to your local box on a local port:
Example:

ssh -f user@personal-server.com -L 2000:personal-server.com:25 -N
The -f tells ssh to go into the background just before it executes the command. This is followed by the username and server you are logging into. The -L 2000:personal-server.com:25 is in the form of -L local-port:host:remote-port. Finally the -N instructs OpenSSH to not execute a command on the remote system.
http://www.revsys.com/writings/quicktips/ssh-tunnel.html