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
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.
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.