Can anyone please explain this??

cur_fy=`grep "CONSOL" $GLDATA/parms/cur_fiscalyear.lis | awk '{print $2}'

Here i don't understand "CONSOL" and awk'{print$2)

Please help me out

cur_fiscalyear.lis contents :

DL 2011
MOL 2011
MV 2011
SF 2010
CONSOL 2011
MVU 2011

Search in $GLDATA/parms/cur_fiscalyear.lis for the line containing "CONSOL" and return the second column of that line. Which, according to that data, should be returning '2011'. Oh, and forgot the first part, cur_fy is the variable holding that information '2011'. Its declaring cur_fy as a variable which expands to whatever grep's looking for which in this case is what's next to "CONSOL" in cur_fiscalyear.lis

---------- Post updated 02-02-11 at 12:14 AM ---------- Previous update was 02-01-11 at 11:57 PM ----------

If you have command line access try this: Type

 df 

and hit enter. Should give some results similar to this :

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/disk0s1           1048576    730240    307856  71% /
devfs                       34        34         0 100% /dev
/dev/disk0s2s1        14677320  13831888    845432  95% /private/var

Good so far? Let's pipe 'df' through 'grep' and look for the word "Filesystem" in the results and only return the line containing that.

 df | grep Filesystem 

should return something like this

 Filesystem           1K-blocks      Used Available Use% Mounted on

. Good so far? Ok last step, let's pipe all of that through 'awk' so we can see what's in the second column of those results "1K-blocks".

 df | grep Filesystem | awk '{print $2}' 

and we get our result. Hope that helped some.

1 Like

Got enough clarity now...

Glad I could help :slight_smile: