Bash: Difference between revisions

From Wiki
Jump to navigation Jump to search
No edit summary
 
(One intermediate revision by the same user not shown)
(No difference)

Latest revision as of 18:28, 28 April 2017

Online Documentation

Parse command-line arguments

for arg in "$@"; do
    # do something with arg
done

bash script examples

  • dicom_dir_to_analyze - convert all Analyze files in a directory tree to DICOM format
  • dns_subnet - find all known DNS entries for class C subnet
  • get_mac - get the current MAC address for an IP address

Looping

sh_files=$(ls -d *.sh 2>/dev/null)

for my_file in "${sh_files[@]}"; do
    echo "$my_file"
done

Logging

./run_my_script > my_log.txt 2>&1