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/'

Join the lines with comma

paste -sd, <<< $'line1\nline2'

Merges given files line by line

paste -d ',:' file1 file2 file3

Add a list of numbers

paste -sd'+' file|bc -l

Prints "hello, world" to the console in very large letters

paste <(banner hello,\ ) <(banner world)

Pastebinit - command-line pastebin client

pastebinit [file]

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

Arch Linux sort installed packages by size

paste <(pacman -Q | awk '{ print $1; }' | xargs pacman -Qi | grep 'Size' | awk '{ print $4$5; }') <(pacman -Q | awk '{print $1; }') | sort -n | column -t

Merge files, joining each line in one line

paste file1 file2 fileN > merged

Paste command output to www.pastehtml.com in txt format.

paste(){ curl -s -S data-urlencode "txt=$($*)" "http://pastehtml.com/upload/create?input_type=txt&result=address";echo;}

Paste one file at a time instead of in parallel

paste serial file1 file2 file3

Create unique email addresses directly from the US census site*Full command in comments

paste -d "." <(curl http://.../dist.female.first http://.../dist.male.first | cut -d " " -f 1 | sort -uR) <(curl http://..../dist.all.last | cut -d " " -f 1 | sort -R | head -5163) | tr "[:upper:]" "[:lower:]" | sed 's/$/@test.domain/g'

No log to trace you

paste <(cut -f1 log.txt) <(cut -f2- log.txt | shuf)