Print the whole line which contains the result of the command cut

Hey everyone

I have a file 'agenda' which contains:

Object          Day          Month           Year
Birthday         09             02             2012

i want to extract from a script the line which contains the day the user typed.
for example if he type 09 the line is showed using the commande cut

using awk in terminal its working but with cut it isnt working it returns me just the number i typed

i did:

cat monagenda | cut -d"            " -f2 | grep 09
cat monagenda | cut -d"            " -f2 | sed -ne '/09/p'

both return just 09 otherwise i want to show the whole line :slight_smile:
thank you and sorry for my bad english.

grep "09" monagenda

Thank you for your answer but im wondering if its possible to use the Cut command.

thank you again for yout interest :slight_smile:

 
$ input=09
$ echo $input
09
 
$ cat test.txt
Object          Day          Month           Year
Birthday         09             02             2012
Birthday         02             02             2012


$ nawk -v inp="$input" 'index($2,inp)>0' test.txt
Birthday         09             02             2012

---------- Post updated at 05:19 PM ---------- Previous update was at 05:17 PM ----------

$ tr -s " " < test.txt | cut -d" " -f2
Day
09

Thank you it worked. never tried this one.

thank you again and have a nice day :slight_smile: