Bash script that accepts short, long, and positional arguments

I asked ChatGPT to "Write me a Bash script that accepts short, long, and positional arguments" and it came up with the following: #!/bin/bash # Define short options options=":s:l:" # Define long options long_options=("short-option:" "long-option:") # Parse options and arguments while getopts "$options" opt; do case $opt in s) short_opt_arg="$OPTARG" ;; l) long_opt_arg="$OPTARG" ;; \?)…

Continue Reading

Grepping a list with a list

The grep command-line utility is a commonly used tool for searching plain text files for lines that match a pattern. For example, you could search a gene or SNP ID in a BED/GFF/GTF file to find out its coordinates. In this post, I will demonstrate how you can search for a list of things in…

Continue Reading