Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Sep 172010

Multiple separators in awk


Sometimes when you split a string using awk, you need to support more than 1 separators, you can use the -F option.


# cat foo.txt | awk -F "[ ?]" '{print $7}'

Now the awk split by a space and by a ?.

 Leave a Reply



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>