Category: Bash

sort – sort lines of text files

$cat test.txt sept aug jan dec oct apr feb mar11 mar1 $sort test.txt apr aug dec feb jan mar1 mar11 oct sept $sort -M test.txt jan feb mar1 mar11 apr aug sept oct dec $

Read More

fold: Wrap input lines to fit in specified width

$cat test.pl use strict; use File::Rename (); use Pod::Usage; main() unless caller; sub main { my $options = File::Rename::Options::GetOptions or pod2usage; mod_version() if $options->{show_version}; pod2usage( -verbose => 2 ) if $options->{show_manual}; pod2usage( -exitval => 1 ) if $options->{show_help}; @ARGV = map {glob} @ARGV if $^O =~ m{Win}msx; File::Rename::rename(\@ARGV, $options); } sub mod_version { print __FILE__ …

Read More

Hacking with runit and sv ( sv – control and manage services monitored by runsv(8) ) commands

$pwd /etc/service $ls hello.sh $mkdir new mkdir: cannot create directory ‘new’: Permission denied $sudo mkdir new $mv hello.sh new/run mv: cannot move ‘hello.sh’ to ‘new/run’: Permission denied $sudo mv hello.sh new/run $ls new $cd new/ $ls run supervise $ls -l total 8 -rw-r–r– 1 root root 11 Oct 24 18:55 run drwx—— 2 root root …

Read More

pr – convert text files for printing

The following shows a command line session with pr command which helps in displaying contents of a file in shell scripts. $cat lkg.txt A for Apple B for Ball C for Cat D for Donkey E for Elephant F for Fox G for Goat H for Horse I for Insect $pr -l 10 lkg.txt A …

Read More

What does true and false commands do ?

commandline session $true $true $? $echo $? 0 $false $echo $? 1 $echo $? 0 $echo $? 0 $false ; true $echo $? 0 $true ; false ; echo $? 1 $true ; false ; echo $? 1 $true ; false ; echo $? 1 $true ; false ; echo $? ; echo $? 1 …

Read More

script — make typescript of terminal session

STITCHED (C) FROM : Virtual Terminals commandline session $script Script started, file is typescript $ls Algorithms bookmark config-files firewall kernel_start.asm loader scripts animation books debian GD kernel_start.s Mail test art.text bugs-general debian-howtos jeffrin language ovlfose typescript beautifulwork cairo Docs kernel linux README web.application $ls -a . beautifulwork config-files GD kernel_start.s ovlfose web.application .. bookmark debian …

Read More

common network utilities/tools

commandline session $ping www.beautifulwork.org PING beautifulwork.org (46.22.210.18) 56(84) bytes of data. 64 bytes from mars.infoclub.in (46.22.210.18): icmp_req=1 ttl=53 time=310 ms 64 bytes from mars.infoclub.in (46.22.210.18): icmp_req=2 ttl=53 time=210 ms 64 bytes from mars.infoclub.in (46.22.210.18): icmp_req=3 ttl=53 time=210 ms 64 bytes from mars.infoclub.in (46.22.210.18): icmp_req=4 ttl=53 time=210 ms 64 bytes from mars.infoclub.in (46.22.210.18): icmp_req=5 ttl=53 time=211 …

Read More

nmap . -O: Enable OS detection

commandline session $nmap 127.0.0.1 Starting Nmap 6.00 ( http://nmap.org ) at 2013-11-24 17:56 IST Nmap scan report for localhost (127.0.0.1) Host is up (0.00019s latency). Not shown: 997 closed ports PORT STATE SERVICE 22/tcp open ssh 25/tcp open smtp 111/tcp open rpcbind Nmap done: 1 IP address (1 host up) scanned in 0.10 seconds $nmap …

Read More

Bash – netstat ( network statistics related )

commandline session $netstat –tcp Active Internet connections (w/o servers) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 debian.local:39585 74.125.169.8:http ESTABLISHED tcp 0 0 debian.local:39586 74.125.169.8:http ESTABLISHED tcp 0 0 debian.local:47951 maa03s17-in-f6.1e:https ESTABLISHED tcp 0 0 debian.local:47203 maa03s17-in-f0.1e1:http ESTABLISHED $ $netstat –tcp –numeric Active Internet connections (w/o servers) Proto Recv-Q Send-Q Local Address …

Read More

GNU/Linux BASH builtin commands

commandline session $pwd /home/jeffrin/playground $which pwd /bin/pwd $ $/bin/pwd /home/jeffrin/playground $/bin/pwd -P /home/jeffrin/playground $pwd -P /home/jeffrin/playground $help pwd pwd: pwd [-LP] Print the name of the current working directory. Options: -L print the value of $PWD if it names the current working directory -P print the physical directory, without any symbolic links By default, `pwd’ …

Read More