Linux cp/rm/mv mandatory overwrite, linuxcp
1. cp/rm/mv force overwrite in Linux (1) and backslash (\) temporarily cancel alias
[root@fz ~]# \cp filename new/filename [root@fz ~]#
(2) unalias cancelling aliases
Note: This is only temporary cancellation of the cp alias, not permanent
[root@localhost ~]# unalias cp [root@localhost ~]# cp filename new/filename [root@localhost ~]#
(3) modify the default configuration file
[root@fz ~]# [root@fz ~]# alias alias cdd='cd /home/data/android/' alias cp='cp -i' alias l='ls -la' alias l.='ls -d .* --color=auto' alias ll='ls -l --color=auto' alias ls='ls --color=auto' alias mv='mv -i' alias rm='rm -i' alias tf='tail -f ' alias vc='vim ~/.bash_profile' alias vs='source ~/.bash_profile' alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
[root@fz test]# vi ~/.bashrc # .bashrc # User specific aliases and functions alias rm='rm -i' #alias cp='cp -i' alias mv='mv -i' # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi
(4) yes command + automatic pipe input yes
[root@fz ~]# yes | cp filename new/filename cp: overwrite `new/filename'? [root@localhost ~]#
II. Implementation of Linux commands in the Java background
Public void copyIcon () throws IOException, InterruptedException {Runtime r = Runtime. getRuntime (); String pai_copy = "\ cp-rf temp/AppIcon/* icon /"; // copy and overwrite String [] cmds = new String [] {"sh", "-c", cmd_copy}; Process p = r.exe c (cmds ); int result = p. waitFor (); if (result = 0) {// indicates that the logger is terminated normally. error ("[copy appIcon succeeded]");} else {logger. error ("[copy appIcon failed]" + pai_copy );}}