0

I have a file which is delimited with ^&^. Here is a snippet from the file.

XML_DOC^&^NUM^&^GEO_REF_ID^&^GRL

I need to perform some operations based on the delimiter. How can I check if the file has ^&^ ? I have tried the below code but that did not work.

if grep -q "^&^" "local/filename.txt"; then
        echo "has"
else
        echo "has not "
fi

Any help is much appreciated.

Alex Raj Kaliamoorthy
  • 2,035
  • 3
  • 29
  • 46

1 Answers1

0
grep -q '\^&^' filename.txt

^ in first position in grep means «start of the string».

ValeriyKr
  • 131
  • 1
  • 6