cp

No such file or directory when 'cp' but not with 'ls'

混江龙づ霸主 提交于 2020-01-07 16:57:27
问题 I am trying to copy the shared preferences folder of my app to the /sdcard partition from my PC using the following ADB command: adb shell su -c "cp /data/data/com.anrapps.pixelbatterysaver/shared_prefs/ /sdcard/appdata/" But this returns cp: Skipped dir '/data/data/com.anrapps.pixelbatterysaver/shared_prefs': No such file or directory . However when executing the ls command, it says that folder is present: adb shell su -c "ls /data/data/com.anrapps.pixelbatterysaver" cache code_cache files

cp 拷贝覆盖文件时不提示的方法

怎甘沉沦 提交于 2020-01-07 07:39:34
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> centos linux 下cp 命令没有直接的强制覆盖参数,实际上,不需要此参数也可以实现自动覆盖。导致会有覆盖提示的原因是cp命令被系统自动默认加上了 -i 参数,也就是交互提示。 知识原因了就简单了,所以确认下是不是这个原因,输入命令 #alias alias cp='cp -i' alias l.='ls -d .* --color=auto' alias ll='ls -alh' alias ls='ls --color=auto' alias mv='mv -i' alias rm='rm -i' alias vi='vim' alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde' 果然如此,去掉 -i 参数 unalias cp 再次操作cp命令,即使目标文件存在也不提示了。 不过有提示安全些,操作完命令后记得改回带 -i 的参数 alias cp='cp -i' 附:查最深几级目录的空间占用情况 du -h --max-dep 2 来源: oschina 链接: https://my.oschina.net/u/1263162/blog/725379

Copy or rsync command

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-31 08:07:09
问题 The following command is working as expected... cp -ur /home/abc/* /mnt/windowsabc/ Does rsync has any advantage over it? Is there a better way to keep to backup folder in sync every 24 hours? 回答1: Rsync is better since it will only copy only the updated parts of the updated file, instead of the whole file. It also uses compression and encryption if you want. Check out this tutorial. 回答2: rsync is not necessarily more efficient, due to the more detailed inventory of files and blocks it

How to copy files found with grep

六月ゝ 毕业季﹏ 提交于 2019-12-31 01:41:08
问题 I am running this command to find all my files that contain (with help of regex)"someStrings" in a tree directory. grep -lir '^beginString' ./ -exec cp -r {} /home/user/DestinationFolder \; It found files like this: FOLDER a.txt -->SUBFOLDER a.txt ---->SUBFOLDER a.txt I want to copy all files and folder, with the same schema, to the destination folder, but i don't know how to do it. It's important copy files and folder, because several files found has the same name and I need to keep it. 回答1:

Bash — locate file, awk copy not working correctly

大兔子大兔子 提交于 2019-12-24 13:47:03
问题 I'm trying to use the following to locate a file then copy the first result to the directory that is set by $dir. It works fine when I don't set a variable and use an absolute path, but that's not what I need. This doesn't work: dir="/path/to/destination/"; mkdir "$dir"; locate -l 1 target_file.txt | awk '{print "cp " $1 $dir " "}' | sh error message is: awk: illegal field $(), name "dir" input record number 1, file source line number 1 cp: fts_open: No such file or directory This works:

Copy several directories to another directory

旧巷老猫 提交于 2019-12-23 22:26:30
问题 How would you copy several directories to a destination directory in docker? I do not want to copy the directory contents , but the whole directory structure. The COPY and ADD commands copy the directory contents, flattening the structure, which I do not want. That is, if these are my sources: . ├── a │ ├── aaa.txt │ └── uuu.txt ├── b │ ├── ooo.txt │ └── ppp.txt └── c └── jjj.txt I want this to be deployed to the docker image: code/ ├── a │ ├── aaa.txt │ └── uuu.txt ├── b │ ├── ooo.txt │ └──

Compare 2 directories and copy differences to directory 3

雨燕双飞 提交于 2019-12-23 16:50:21
问题 I have three directories. I would like to compare directory1 with directory2, then take those changes/new files and copy them over to directory3. Is there an easy way to do this, maybe by using linux diff and cp commands? I'm open to ideas. Thanks! Andrew 回答1: I believe this is what you want from your description. for file in dir2/*; do file_in_dir1=dir1/$(basename ${file}) if [ ! -e ${file_in_dir1} ]; then # If the file in dir2 does not exist in dir1, copy cp ${file} dir3 elif ! diff ${file}

Copy a file using a makefile at runtime

浪子不回头ぞ 提交于 2019-12-22 08:07:33
问题 I used to compile my programs with batch scripts on windows but I recently discovered makefiles which are much more efficient. I had this line in my .bat file that copied some dlls to the current directory at runtime and it worked perfectly. copy C:\lib\glfw\glfw.dll I tried the same line in my makefile and even tried the alternative cp but my terminal prints this error even tho the file is IN the location I specified process_begin: CreateProcess(NULL, copy C:\lib\glfw\glfw.dll, ...) failed

How to pipe output from grep to cp?

随声附和 提交于 2019-12-20 10:26:22
问题 I have a working grep command that selects files meeting a certain condition. How can I take the selected files from the grep command and pipe it into a cp command? The following attempts have failed on the cp end: grep -r "TWL" --exclude=*.csv* | cp ~/data/lidar/tmp-ajp2/ cp: missing destination file operand after ‘/home/ubuntu/data/lidar/tmp-ajp2/’ Try 'cp --help' for more information. cp `grep -r "TWL" --exclude=*.csv*` ~/data/lidar/tmp-ajp2/ cp: invalid option -- '7' 回答1: grep -l -r "TWL"

grep file for string and copy directory to another directory

醉酒当歌 提交于 2019-12-20 04:36:11
问题 I have large number of directories with just one file -- index.html -- in each directory. I would want to use grep to look for pattern in file and then copy the directory along with the file to another directory. Example for copying files, I have seen, but I would want to copy the directory with the file in to another directory. so say following are the list of matching files with directory using grep -rl "string" source_dir d1/index.htmk d2/index.html d3/index.html ... ... a long list. Now