I'm trying to build a script that deletes some lines from a txt file after evaluating if the line is ok or needs to be removed.
The sed command evaluates to something like this:
sed -i '4d' file.txt
Everything is fixed except for the number of the line which can change, the command inside the script literally looks like this:
sed -i \'$lineNum\' $file
But it fails with error:
sed: -e expression #1, char 1: unknown command: `''
However if I run the same command on the command line, it works as expected.
Edit:
Removed sh tag since I'm actually using ksh, the editor I'm using is vi
I'm running on:
Distributor ID: RedHatEnterpriseServer
Description: Red Hat Enterprise Linux Server release 6.4 (Santiago)
Release: 6.4
Codename: Santiago