1836579 Members
1502 Online
110102 Solutions
New Discussion

Re: Shell script help

 
SOLVED
Go to solution
Joe Robinson_2
Super Advisor

Shell script help

I am looking for a command to check if there is a form feed (^L) at the beginning of a file before continuing processing. I have one application that was written differently than all my others and I need to strip that character before using it as input to another app. It seems to me that there is a way to grep for it and explicitly look at the beginning of a line - does this seem familiar to any of you out there?

Thanks in advance,
JR
3 REPLIES 3
Mark Greene_1
Honored Contributor
Solution

Re: Shell script help

The carat (^) tells grep to look at the beginning of a line:

grep "^^L" [filename]

mark
the future will be a lot like now, only later
Joe Robinson_2
Super Advisor

Re: Shell script help

Mark,

Thanks for the tip! Just what the dr. ordered!

JR
Rodney Hills
Honored Contributor

Re: Shell script help

If you do-

if grep -q "^L" filename ; then
echo "File has control-L"
fi

The -q option causes grep to stop on the first ^L. Otherwise grep will scan the entire file for all ^L.

My 2 cents

-- Rod Hills
There be dragons...