Skip to content

paste

Paste command is one of the useful commands in Unix or Linux operating system. It is used to join files horizontally (parallel merging) by outputting lines consisting of lines from each file specified, separated by tab as delimiter, to the standard output


Generate one beep tone only

play -q -n synth 0.09 pluck E4 vol 0.7 echo 0.8 0.7 25 0.3 >/dev/null 2>&1

Generate random tone

paste <(seq 7 | shuf | tr 1-7 A-G) <(seq 7 | shuf) | while read i j; do play -qn synth 1 pluck $i synth 1 pluck mix $2; done

Generate a random long tone

notes=(A3 C4 D4 E4 G4 A4 C5 D5 E5 G5)
durs=(0.10 0.12 0.14 0.16 0.18 0.20)

for k in {1..32}; do
  n="${notes[RANDOM % ${#notes[@]}]}"
  d="${durs[RANDOM % ${#durs[@]}]}"
  play -q -n synth "$d" pluck "$n" vol 0.6 reverb 20 >/dev/null 2>&1
done

rpeggiated cyber riff (repeatable, actually melodic)

riff=(E4 G4 B4 E5 D5 B4 G4 D4)
for rep in {1..6}; do
  for n in "${riff[@]}"; do
    play -q -n synth 0.14 pluck "$n" vol 0.7 reverb 15 >/dev/null 2>&1
  done
done

Query CPU Temperature Using /sys/class/thermal

paste <(cat /sys/class/thermal/thermal_zone*/type) <(cat /sys/class/thermal/thermal_zone*/temp) \
|column -s $'\t' -t|sed 's/\(.\)..$/.\1°C/'

Print core temp without lm_sensors

paste \
  <(for d in /sys/class/hwmon/hwmon*; do
        name=$(<"$d/name")
        for t in "$d"/temp*_input; do
            [ -r "$t" ] || continue
            lbl="${t%_input}_label"
            label=$( [ -r "$lbl" ] && <"$lbl" || basename "$t" )
            printf "%s/%s\n" "$name" "$label"
        done
    done) \
  <(for d in /sys/class/hwmon/hwmon*; do
        for t in "$d"/temp*_input; do
            [ -r "$t" ] && cat "$t"
        done
    done) |
column -t |
sed 's/\(.\)..$/.\1°C/'

Another version to print core temp without lm_sensors

paste \
  <(for d in /sys/class/hwmon/hwmon*; do
        name=$(<"$d/name")
        for t in "$d"/temp*_input; do
            [ -r "$t" ] || continue
            lbl="${t%_input}_label"
            label=$( [ -r "$lbl" ] && <"$lbl" || basename "$t" )
            printf "%s/%s\n" "$name" "$label"
        done
    done) \
  <(for d in /sys/class/hwmon/hwmon*; do
        for t in "$d"/temp*_input; do
            [ -r "$t" ] && cat "$t"
        done
    done) |
column -t |
sed 's/\(.\)..$/.\1°C/'