Linux cp/rm/mv mandatory overwrite, linuxcp

Source: Internet
Author: User

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
  • Enter the alias command to check that cp, mv, and rm-I are used in the system.

   [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'
  • Modify ~ /. Bashrc, add the '#' comment before "alias cp = 'cp-I.

    [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
  • Restart or execute source ~ /. Bashrc make the command take effect
(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 );}}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.