# Extract from a file

**URL:** <https://community.unix.com/t/extract-from-a-file/142542>\
**Category:** Shell Programming and Scripting\
**Created:** [May 8, 2002, 5:02pm UTC](https://community.unix.com/t/extract-from-a-file/142542 "2002-05-08T17:02:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![odogbolu98](https://community.unix.com/letter_avatar/odogbolu98/32/5_5575768a8748004e209b776fc1b2916d.png) [@odogbolu98](https://community.unix.com/u/odogbolu98)\
**Post date:** [May 8, 2002, 5:02pm UTC](https://community.unix.com/t/extract-from-a-file/142542/1 "2002-05-08T17:02:38Z")

</div>

Hi guys,

Thanks for this forum. It's been very helpful in improving my understanding of unix.

I have 2 questions.

a. eg I have the following

```
  big\_tom\_get_back\("final"\) in a file, how can I use awk or sed to xtract the word "final" without the quote from the string.

 I try using cat tempfile|grep big\_tom_get |awk \`/\\\(\\" $1 \\"\\\)

```

This doesn't seem to work.

b. The second question is that I want to use the same command to loop through all the temp files stored in different location/directory. How can I do that? Does the find commnd work here?

I would appreciate any assistance on this

Thanks,

Odogbolu98:rolleyes:

---

<div class="post-metadata">

**Author:** ![system](https://community.unix.com/uploads/default/original/2X/c/c7e9e16a595259edafe88615719d5c5dcda035c2.png) [@system](https://community.unix.com/u/system)\
**Post date:** [May 8, 2002, 5:23pm UTC](https://community.unix.com/t/extract-from-a-file/142542/2 "2002-05-08T17:23:51Z")

</div>

Read the man page on awk and you will find the -F option - use it to change the field separator - set it to " and print $2 should give you what you want.

Read the man page on find - check out the exec option.

---

<div class="post-metadata">

**Author:** ![odogbolu98](https://community.unix.com/letter_avatar/odogbolu98/32/5_5575768a8748004e209b776fc1b2916d.png) [@odogbolu98](https://community.unix.com/u/odogbolu98)\
**Post date:** [May 8, 2002, 5:55pm UTC](https://community.unix.com/t/extract-from-a-file/142542/3 "2002-05-08T17:55:59Z")

</div>

Can I have an example of that. It seems to me that " can't be used as a delimiter. what I mean is  
eg. -F"\t" represents tab as a delimiter, when I use -F"\"" it gives unmatched ". message. Am I doing something wrong?

Thanks

---

<div class="post-metadata">

**Author:** ![system](https://community.unix.com/uploads/default/original/2X/c/c7e9e16a595259edafe88615719d5c5dcda035c2.png) [@system](https://community.unix.com/u/system)\
**Post date:** [May 9, 2002, 11:00am UTC](https://community.unix.com/t/extract-from-a-file/142542/4 "2002-05-09T11:00:50Z")

</div>

Example (done in csh - should work with minor changes in other shells)

set junk='big\_tom\_get\_back("final")'  
echo $junk|awk -F\" '{print $2}'  
final

---

<div class="post-metadata">

**Author:** ![odogbolu98](https://community.unix.com/letter_avatar/odogbolu98/32/5_5575768a8748004e209b776fc1b2916d.png) [@odogbolu98](https://community.unix.com/u/odogbolu98)\
**Post date:** [May 10, 2002, 2:40pm UTC](https://community.unix.com/t/extract-from-a-file/142542/5 "2002-05-10T14:40:36Z")

</div>

Thanks, I really appreciate your help.

Regards,

Odogbolu98
