head
takes the first lines from a file, and the -n
parameter can be used to specify how many lines should be extracted:
line=$(head -n 1 filename)
More Related Contents:
- How to concatenate string variables in Bash
- Why can’t I change directories using “cd” in a script?
- Why do you need ./ (dot-slash) before executable or script name to run it in bash?
- What are the special dollar sign shell variables?
- How can I repeat a character in Bash?
- Echoing the last command run in Bash?
- Extract data from log file in specified range of time [duplicate]
- Capture stdout to a variable but still display it in the console
- YYYY-MM-DD format date in shell script
- Force flushing of output to a file while bash script is still running
- Get current directory name (without full path) in a Bash script
- How do I redirect output to a variable in shell? [duplicate]
- Delete all lines beginning with a # from a file
- Variable interpolation in the shell
- Getting the parent of a directory in Bash
- Loop over directories with whitespace in Bash
- What does ” 2>&1 ” mean?
- When should I double-quote a parameter expansion? [duplicate]
- Bash script – “/bin/bash^M: bad interpreter: No such file or directory” [duplicate]
- Optional option argument with getopts
- bash script order of execution
- bash piping prevents global variable assignment
- Use GNU find to show only the leaf directories
- Get the name of the caller script in bash script
- How does testing if a string is ‘greater’ than another work in Bash?
- Reading lines from two files in one while loop
- What is the shortest way to get n-th column of an output?
- How do I kill a backgrounded/detached ssh session?
- Creating tar file and naming by current date
- Can bash script be written inside a AWS Lambda function