Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am extracting a page from website using cURL command.

curl "www.google.com" -s |  w3m -dump -T text/html > foo.txt

The w3m command outputs the HTML page in a much more simpler format so that the string manipulation in the foo.txt is simpler now.

Now, I have some values in my foo.txt which get extracted as below.

Assistant director at Hollywood studios
Student at University of Texas at Arlington

Now, I need to extract only the values after at to store in my database. How can I do it? For example, for the above input, I need the values as,

Hollywood Studios
University of Texas at Arlington
share|improve this question
up vote 2 down vote accepted

Another option is to pipe your text into grep and cut:

grep -o ' at .*$' foo.txt | cut -c5-

This will extract the longest string for each line which starts with ' at '. The cut will then trim the leading ' at '.

share|improve this answer

Another way would be to replace the first occurrence of at with a tab, so now you have a tab delimited file and you can use awk properly:

$ sed 's/ at /\t/' foo.txt | awk -F'\t' '{print $1" :: "$2}'
Assistant director :: Hollywood studios
Student :: University of Texas at Arlington

Or, the same thing in Perl:

$ perl -ne '/(.+?) at (.+)/; print "$1 :: $2\n"' foo.txt

or even

$ perl -F'\sat\s' -lane 'print "$F[0] :: @F[1..$#F]"' foo.txt
share|improve this answer

You can use at as column separator in awk. The following should work:

awk -F'at' '{print $2}' foo.txt
share|improve this answer
Some words will include those letters together... Also, you'd need $3 in the case of Texas at Arlington. – jasonwryan Feb 10 '14 at 23:04
aha gotcha! let me think. – Ketan Feb 10 '14 at 23:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.