cut

Kurt Wall kwall
Mon May 17 12:02:12 PDT 2004


In a 0.7K blaze of typing glory, M.W. Chang wrote:
> root at server: init.d> ps ax | grep bttrack | grep -v grep
>  6016 ?        S     29:50 /usr/bin/python /usr/bin/bttrack.py --p
> 
> There is a leading a space char in the line. I couldn't use `cut -f 1 -d 
> " "` on the line. What's the neatest command to remove all leading 
> spaces (1..n) in a line of text?

sed:

$ ps ax | grep bttrack | sed -e 's/^. //g'

To wit:

$ ps ax | grep lib | sed -e 's/^. //g'
836 ?        S      0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/run/mysql/mysql.pid
856 ?        S      0:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysql/mysql.pid --skip-locking
921 ?        S      0:00 /usr/libexec/postfix/master
928 ?        S    417:17 /usr/X11R6/bin/X -auth /usr/X11R6/lib/X11/xdm/authdir/authfiles/A:0-zD3LSl
[kurtw]$ ps ax | grep lib | sed -e 's/^. //g'
836 ?        S      0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/run/mysql/mysql.pid
856 ?        S      0:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --pid-file=/var/run/mysql/mysql.pid --skip-locking
921 ?        S      0:00 /usr/libexec/postfix/master
928 ?        S    417:17 /usr/X11R6/bin/X -auth /usr/X11R6/lib/X11/xdm/authdir/authfiles/A:0-zD3LSl

> 
> -- 
>   .~.    http://toylet.homeip.net
>  / v \   Linux 2.4.26
> /( _ )\  12:18am up 10 days 1:41
>   ^ ^    load average: 1.09 1.13 1.17
> -- 
> Scanned by ClamAv - http://www.clamav.net
> _______________________________________________
> Linux-users mailing list
> Linux-users at smtp.linux-sxs.org
> Unsubscribe/Suspend/Etc -> 
> http://smtp.linux-sxs.org/mailman/listinfo/linux-users

-- 
Just go with the flow control, roll with the crunches, and, when you
get a prompt, type like hell.



More information about the Linux-users mailing list