Reputation: 1109
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 [email protected] 414 2248893
Terry Tools Orlando Florida [email protected] 407 2439812
Park Tools Riviera Beach Florida [email protected] 516 5370923
Bike Tools Orlando Florida [email protected] 407 3420983
tail: /home/renter_list: invalid number of lines
Upvotes: 1
Views: 1414
Reputation: 183321
The error-message seems to be saying that your script starts with #!bin/bash
instead of #!/bin/bash
(that is, that you're missing a /
before bin/bash
).
Update: Your new error-message is because you're not entering a number. You have an echo
, followed by two read
s. For the first read
, you're entering 4
, but for the second, you're just hitting Enter. So the tail
command is tail -n /home/rent_list
.
If you want to use the same number for both commands, you can write:
echo -n "What rows need to be cut from your data file: "
read num_rows
head -n $num_rows /home/rent_list
tail -n $num_rows /home/rent_list
Upvotes: 4