Use shuf
with the -n
option as shown below, to get N
random lines:
shuf -n N input > output
More Related Contents:
- How to generate random number in Bash?
- what exactly env command do? [duplicate]
- Quick-and-dirty way to ensure only one instance of a shell script is running at a time
- What is the purpose of the : (colon) GNU Bash builtin?
- How to store standard error in a variable
- Multi-dimensional arrays in Bash
- How do I check if a directory exists in a Bash shell script?
- Capture stdout and stderr into different variables
- Checking from shell script if a directory contains files
- How to determine the current interactive shell that I’m in (command-line)
- Associative arrays in Shell scripts
- How to get the part of a file after the first line that matches a regular expression
- Trying to split a string into two variables
- How to represent multiple conditions in a shell if statement?
- How to replace ${} placeholders in a text file?
- Escape dollar sign in string by shell script
- Open and write data to text file using Bash?
- How to check if running in Cygwin, Mac or Linux?
- What’s a concise way to check that environment variables are set in a Unix shell script?
- Source files in a bash script
- executing shell command in background from script [duplicate]
- Use sed to replace all backslashes with forward slashes
- Waiting for background processes to finish before exiting script
- Variables as commands in Bash scripts
- How to split a file into equal parts, without breaking individual lines? [duplicate]
- Why does “local” discard the return code of a command?
- What does “<
- Assign a makefile variable value to a bash command result?
- Comparing PHP version numbers using Bash?
- How to include nohup inside a bash script?