I want to prompt a user via command line & ask what specific rows need to be cut from a data file using either head or tail. My script will employ head and tail using the inputs as variables for both head and tail commands. This is what I have thus far along with the error message:
echo -n "What rows need to be cut from your data file: "
read before
read after
head -n $before /home/rent_list
tail -n $after /home/rent_list
Error message:
-bash: ./rent_list: bin/bash: bad interpreter: No such file or directory
Update: This is what I am getting now:
What rows need to be cut from your data file: 4
Mack Tools Milwaukee Wisconsin mj414@yahoo.com 414 2248893
Terry Tools Orlando Florida 407@yahoo.com 407 2439812
Park Tools Riviera Beach Florida tp123@hotmail.com 516 5370923
Bike Tools Orlando Florida baptiste41@gmail.com 407 3420983
tail: /home/renter_list: invalid number of lines
The error-message seems to be saying that your script starts with
#!bin/bashinstead of#!/bin/bash(that is, that you’re missing a/beforebin/bash).Update: Your new error-message is because you’re not entering a number. You have an
echo, followed by tworeads. For the firstread, you’re entering4, but for the second, you’re just hitting Enter. So thetailcommand istail -n /home/rent_list.If you want to use the same number for both commands, you can write: