[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: command for swapping of two files or two dirs?
From: |
Alex fxmbsw7 Ratchev |
Subject: |
Re: command for swapping of two files or two dirs? |
Date: |
Fri, 26 Mar 2021 23:28:15 +0100 |
swap_maybe_safer() { declare t=
while [[ -e ${t:=.$SRANDOM$SRANDOM}.} ]] && t= ; do :; done
cp -p "$1" "$t"
mv "$2" "$1"
mv "$t" "$2"
}
On Fri, Mar 26, 2021 at 6:11 PM Peng Yu <pengyu.ut@gmail.com> wrote:
>
> Hi,
>
> I can use mv to program a swap bash script. Or use renameat2(...,
> RENAME_EXCHANGE) on Linux and renameatx_np(..., RENAME_SWAP) on Darwin
> to make a swap C program.
>
> But since this should be a commonly used function, is there already an
> existing well-maintained command for this purpose?
>
> --
> Regards,
> Peng
>
- Re: command for swapping of two files or two dirs?, (continued)
- Re: command for swapping of two files or two dirs?, Greg Wooledge, 2021/03/26
- Re: command for swapping of two files or two dirs?, Alex fxmbsw7 Ratchev, 2021/03/26
- Re: command for swapping of two files or two dirs?, Peng Yu, 2021/03/26
- Re: command for swapping of two files or two dirs?, Alex fxmbsw7 Ratchev, 2021/03/26
- Re: command for swapping of two files or two dirs?, Eli Schwartz, 2021/03/26
- Re: command for swapping of two files or two dirs?, Alex fxmbsw7 Ratchev, 2021/03/26
- Re: command for swapping of two files or two dirs?, Reuti, 2021/03/26
- Re: command for swapping of two files or two dirs?, Alex fxmbsw7 Ratchev, 2021/03/26
- Re: command for swapping of two files or two dirs?, Peng Yu, 2021/03/26
- Re: command for swapping of two files or two dirs?, Reuti, 2021/03/26
Re: command for swapping of two files or two dirs?,
Alex fxmbsw7 Ratchev <=