5 Column Output
Tagged with: column, columns, command, Linux, output, terminal
Wednesday, March 12th, 2008 11:31 PM
Divide terminal into 5 columns
ls /tmp | pr -T5 -W$COLUMNS
Divide terminal into 5 columns
ls /tmp | pr -T5 -W$COLUMNS
Execute a command and get its results using python in Linux
import commands
result = commands.getoutput("ls")
One can use awk to get a specific column from a command output…
First column of the command
date|awk '{print $1}'
11th Column of the command
ps aux|awk '{print $11}'
Use a different Field separator
cat /etc/passwd|awk -F ':' '{print $1}'
[tags]awk,sed,shell,script,output,filter,text,cli,linux,string,separator[/tags]
Get just the first line of the output of a command…
<command>|head -n1
ls -1|head -n1