I'm working on terminal and running a .sh file and I want to count the lines in another file and save it as a variable to be used in this .sh file.
I'm using this command sed -n '$=' /lines.txt when I run this it displays the number of lines on terminal but I want to save it in a variable named numberoflines. If anyone could advise how to do this.
1 Answer
numberoflines=$(sed -n '$=' /tmp/lines.txt)