Grep Command

Hi,

I Want to grep the 500th character of a line in a file. please help on this.

Thanks in advance

grep "^.\{499\}X" file

Where X is the character you are grepping on.

cut -c 500-500 < filename

Is this you want?

Or, depending on what you mean?

cat filename | cut -b 500

using perl:-

X is the wanted char.

perl -wnl -e '/^.{499}X/ and print ;'  infile.txt

;);):stuck_out_tongue:

---------- Post updated at 14:11 ---------- Previous update was at 14:07 ----------

or if you want char number 500 :-

perl -wpl -e 's/^.{499}(.).+/$1/g ;' infile.txt

:cool::cool::cool:

My 500th character starts with R, I need to search that particular character..

---------- Post updated at 05:47 PM ---------- Previous update was at 05:44 PM ----------

grep "^.\{499\}X" file

I want something similar to this... But it is showing the following error in shell script

"Invalid \{\} repetition." plz help

perl -wnl -e '/^.{499}R/ and print ;'  infile.txt

:cool::cool::cool::wink:

egrep '^.{499}R' infile