perl -e 'system "grep -A 3 ^id: $ARGV[0]"' file #### grep -A 3 ^id: file