/
hubbitus
/
shell.scripts
Обзор
Документация
Войти
/
hubbitus
/
shell.scripts
Код
Запросы
0
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
swap
10 строк
380 B
Pavel Alexeev
Add simple swap script
03 дек 2019, 00:41
03 дек 2019, 00:41
13cdf03
Код
Авторство
О чём код?
#!/bin/bash # Swap content of two files # By https://stackoverflow.com/questions/1115904/shortest-way-to-swap-two-files-in-bash/11075489#11075489 : ${1?"Not enough arguments: `basename $0` firstFile secondFile"} : ${2?"Not enough arguments: `basename $0` firstFile secondFile"} tmpfile=$(mktemp $(dirname "$1")/XXXXXX) mv "$1" "$tmpfile" && mv "$2" "$1" && mv "$tmpfile" "$2"