I want to pass the argument in the console while running a script called run.sh as follows
run.sh first count
for example:
./run.sh first 10
i have to pass those first and 10 to the script here
cat file1.txt | head -10
here first should refer to head and count value should be 10. how can i do this?
Bash supports positional parameters . Parameters one through nine are stored in $1 .. $9 , but you can have more stored in $ * or $@ .
For example:
#!/bin/bash
# Read x lines from some arbitrary file.
head -n "$2" "$1"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.