excluding a character

Hi,
I want to compare the percentage value from the df -k output for which I'm doing:
df -k|grep u01|awk '{print $4}'
--this returns with % sign, how do i exclude this??
-Karthik

You're really close - you can add to the end of that:

| sed 's/%//'

Or do it all in awk...

df -k | awk '/u01/ {sub("%","",$4); print $4}'

thank you guys

Even better! awk and sed are tough commands to master but incredibly powerful; I wish I knew them thru and thru...

Much of the real power behind many of the tools in UNIX comes from an understanding of "regular expressions".

A coulple of nice sites to visit and learn from:

http://en2.wikipedia.org/wiki/Regular_expression

A little history (from wikipedia):

A regular expression (abbreviated as regexp or regex) is a string that describes a whole set of strings, according to certain syntax rules. These expressions are used by many text editors and utilities (especially in the Unix operating system) to search bodies of text for certain patterns and, for example, replace the found strings with a certain other string.

The origin of regular expressions lies in automata theory and formal language theory (both part of theoretical computer science). These fields study models of computation (automata) and ways to describe and classify formal languages. A formal language is nothing but a set of strings. In the 1940s, Warren McCulloch and Walter Pitts described the nervous system by modelling neurons as small simple automata. The mathematician, Stephen Kleene, later described these models using his mathematical notation called regular sets. Ken Thompson built this notation into the editor qed, then into the Unix editor ed and eventually into grep. Ever since that time, regular expressions have been widely used in Unix and Unix-like utilities such as: expr, awk, Emacs, vim, lex, and Perl. Most tools use an implementation of the regex library built by Henry Spencer.

Cheers,

Keith