Bash Handbook (🚧Continuous Update)

1. Check if a file path represented by environment variable exists [[ "$(cat ${ENV_VARIABLE})" ]] || printf "env is not exported." 2. Get the file name from the full path echo "$basename -a /home/foo/abc.txt" # Output abc.txt 3. Extract the specific cell value from a table output For example, the output of the command nomad node status -address=https://127.0.0.1:4646 ID DC Name Class Drain Eligibility Status d88b0888 dc1 oscarzhou-B550-AORUS-ELITE-AX-V2 <none> false eligible ready If we want to get value of the datacenter dc1 where is [2,2] in the array. The solution is ...

DigitalOcean Referral Badge
Sign up to get $200, 60-day account credit !