LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   field separation not using awk -f option (https://www.linuxquestions.org/questions/linux-newbie-8/field-separation-not-using-awk-f-option-669990/)

sagar.tv 09-15-2008 04:19 AM

field separation not using awk -f option
 
Hi all,
my problem is to separate two fields which are separated by = not using the awk command..
suppose if I give " -dir=/usr/home/ " this line I should be able to get "-dir" and "/usr/home" separately. in this case = is the separation character. so is there any way I can separate two fields not using awk -f command..???

jan61 09-15-2008 01:28 PM

Moin,

this is because the -f option of awk does NOT define field separators. It defines a script to execute in awk. You want to use -F.

If you do not want to use awk, you could use cut:
Code:

FNAME=`echo "-dir=/my/path" | cut -f1 -d=`
FPATH=`echo "-dir=/my/path" | cut -f2 -d=`

Jan


All times are GMT -5. The time now is 02:10 PM.