Grep command error

I am using a command but getting an error despite of modifying it many times.

Pattern=`grep story file|cut -c 19-24`

Where as 'story' is the pattern to be matched and i want to cut the value of characters ranging from 19 to 24 when this pattern is found in a variable.

file consists of below log:

A short story is a brief work of literature
usually written in narrative prose
Emerging from earlier oral telling traditions

Am I doing something wrong. This command is being written in a shell script

What is not working? What error do you get? Why don't you give us a clear and complete picture?

grep: invalid option -- -
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.

This should give you brief as output.

but when i am trying to run..it giving an error ..i want a output "brief"

What do you use for story . Do you use proper quoting around it?

yes I used single and double quotes both but did not work.

Is your file actually named "file"?

If you are simplifying your code in anyway, don't. If this is part of a large script, if you can, extract the smallest amount of code that reproduces the error into its own script file which anyone else can use.

Also, the operating system/grep implementation which you are using may be relevant.

Regards,
Alister

Can't be! In the code snippet you gave in post #1, there was no - option to grep! Please be consistent, and, as alister wrote, give us a meaningful extraction from what is not behaving as you would expect.

First try only grep command and see if it works. If yes, then pipe it to cut command.
Also run 'which grep' to make sure you are running correct version of grep.

May be the file has control characters as in not in unix format. cat -A input_file should sort out that.

--ahamed

The file's contents do not affect the option handling code.

Regards,
Alister