I’m trying to write a script that takes two files and a number as its parameters and copies that number of lines from one file to the other. Here’s what I have:
#!/bin/bash
file1=$1
file2=$2
lines=$3
sed -n '1,\'$lines\'p' $file1 > $file2
Obviously the problem is the formatting of the $lines parameter. What’s the right way to do this? Thanks!
sed -n -e “1,${lines}p” $file1 > $file2
alternately:
head -n $lines $file1 > $file2