-3

I want to save the number of lines minus 2 into a shell variable.

I have tried this:

eval a = wc -l  meny1.xml | awk '{print $1}

tail a-2 meny1.xml >> tmp

for saving the number of line of a file and then decrease it by 2.

but it doesn't do the trick

how should I write this?

Mörre
  • 5,699
  • 6
  • 38
  • 63
Elad Benda2
  • 13,852
  • 29
  • 82
  • 157

2 Answers2

1

You could try something like:

$ export count=$((`wc -l < myfile` - 2))
$ echo $count
2
$ wc -l file
4
SMA
  • 36,381
  • 8
  • 49
  • 73
0

You can try something like

$ a=$(wc -l file | awk '{print $1-2}')
$ echo $a
3

$ wc -l file
5 file
nu11p01n73R
  • 26,397
  • 3
  • 39
  • 52