I'm trying to run a command called bedtools shuffle on a file 5 times and save each run as with its counter after the filename (i.e. SHUFFLE1... SHUFFLE 5).
Here is my code but I keep getting the error message below:
for i in {1..5}; do bedtools shuffle -i '/PATH/wgEncodeBroadHistoneOsteoblH3k27acStdPk.broadPeak_use' -g '/PATH/chrom.sizes'> rm -f '/PATH/wgEncodeBroadHistoneOsteoblH3k27acStdPk.broadPeak_use_SHUFFLED${i}.bed'; done
-bash: rm: cannot overwrite existing file
-bash: rm: cannot overwrite existing file
-bash: rm: cannot overwrite existing file
-bash: rm: cannot overwrite existing file
-bash: rm: cannot overwrite existing file
Please advise!
Related
The title pretty much explains what I want to accomplish. I was able to accomplish half the task which was to summarise all the files which were of type ASCII in my Home directory but not able to accomplish the other half which was to remove those files.
mohit#dell3568:~$ ls | xargs -n 1 -I{} file {} | grep ASCII | cut -f1 -d ":" | xargs -n 1 -I{} rm -i {}
rm: remove regular file 'a'? rm: remove regular file 'adfasdf'? rm: remove regular file 'asdf'? rm: remove regular file 'auto-remove-NON_REMOVED'? rm: remove regular file 'BIGGEST_PACKAGE'? rm: remove write-protected regular file 'config_DOT_dpkg-new.bak'? rm: remove regular file 'CutCommandInLinuxPrac'? rm: remove regular file 'duplicateTorrentFilesInTorrentTwoFolderUnderTheCompleteWebDevCourse.txt'? rm: remove regular file 'etc_mono_config.bak'? rm: remove regular file 'FileForGrepPrac'? rm: remove regular file 'FolderView.qml.bak---Copied_as_I__made_changes_----590and607LinesAreChanged.bak'? rm: remove regular file 'GRUB_EaSy_22'?
I wasn't able to delete the files as it was not giving the option to select 'yes' or 'no'. Thanks for any help.
rm: remove regular file 'headTestFileDelMeLater'?
rm: remove regular file 'historyOUT.txt'?
rm: remove regular file 'JavaForLogRead.java'?
rm: remove regular file 'online-terminal-PS1'?
rm: remove regular file 'packagesSize.txt'?
rm: remove regular file 'TableExample'?
rm: remove regular file 'TankGame'?
rm: remove regular file 'VeryImpUSEFULcommandsLINUX'?
rm: remove regular file 'Xresources'?
How to remove a file(s) with strange name in ubuntu?
I used ssh-keygen, I think I copied the command line with the linebreak at the end and created two files with a very strange file name.
https://ibb.co/0mC5fMj
Try to delete
rm \'\'$\'r\'
But result:
rm: cannot remove ''\'''\''$'\''r'\''': No such file or directory
Try to add -- at the beginning of the file name.
$ rm -v -- #file
$ rm -v -- "#file"
Try to add ./ at the beginning of the file name.
$ rm -v ./#file
If the previous tips do not work, you can still remove it using the inode number with:
ls -li
output:
5133242 -rw-r--r-- 1 user #*%/file
then using find
$ find . -inum 5133242 -delete
ATTN: shell gods ;)
I can't seem to figure out how to delete a file with a unicode character 0x2400 in the filename on OSX (Example: ␀.test).
It's not a NULL character per-se, but a "symbol for null". (See: http://unicodelookup.com/#null/1)
Script - How to Reproduce
#!/usr/bin/env bash
dir="${HOME}/test_dir"
# Create Directory: ~/test_dir
if [ ! -d "${dir}" ]; then
printf "\nCreating Directory: ${dir}\n"
mkdir ${dir}
fi
# Create our character
char=$'\xE2\x90\x80'
# Create filename
file="${dir}/${char}.test"
# Create the File
printf "\nCreating File: ${file}\n"
touch ${file}
Delete the file... NOPE!
# Attempt 1 - Delete File
printf "\nDeleting File: ${file}\n"
rm -rf ${file}
Delete the whole directory... NOPE!
# Attempt 2 - Delete Directory
printf "\nDeleting Directory: ${file}\n"
rm -rf ${dir}
Delete the file via inode... NOPE!
# Attempt 3 - Delete File
inode=$(ls -i1 ${dir} | awk '{print $1}')
printf "\nDeleting via Inode: ${inode}\n"
find ${dir} -inum ${inode} -exec rm -i {} \;
The whole script should output something like this:
Creating File: /Users/bsmith/test_dir/␀.test
Deleting File: /Users/bsmith/test_dir/␀.test
rm: /Users/bsmith/test_dir/␀.test: Invalid argument
Deleting Directory: /Users/bsmith/test_dir/␀.test
rm: /Users/bsmith/test_dir/␀.test: Invalid argument
rm: /Users/bsmith/test_dir: Directory not empty
Deleting via Inode: 68592933
remove /Users/bsmith/test_dir/␀.test? y
rm: /Users/bsmith/test_dir/␀.test: Invalid argument
This command works for me:
rm ?.test
But sadly it is very probable that it will NOT work for you.
It is a known bug of osx:
Is it impossible to delete/move a file named “␀” on mac?
Rename folder with odd characters
The sure bet is to boot from a pen drive with some Linux OS, mount the file system in such Linux, and erase the file. It is sure that files with such names could be erased in Linux.
I run in Debian 8.1, GNU bash, version 4.3.30(1)-release (x86_64-pc-linux-gnu) and Lenovo G50-30 with 500 GB SSD and 8 GB flash memory:
shopt -s extglob
cp -r !(Backups.backupdb/) /home/masi/Documents/
but it will copy also everything from the directory Backups.backupdb/, confirmed at the end of copying.
Messages during the copying process
After 2h copying
cp: cannot stat ‘Backups.backupdb/masi\’s MacBook Air/2015-06-25-233115/Macintosh HD/System/Library/Image Capture/Automatic Tasks/MakePDF.app/Contents/Resources/ko.lproj/3x5로 자르기.mkpdf’: No such file or directory
cp: cannot stat ‘Backups.backupdb/masi\’s MacBook Air/2015-06-25-233115/Macintosh HD/System/Library/Image Capture/Automatic Tasks/MakePDF.app/Contents/Resources/ko.lproj/3x5에 맞추기.mkpdf’: No such file or directory
...
cp: cannot stat ‘Camera Uploads/2015-06-29 11.51.36.jpg’: Invalid argument
cp: cannot stat ‘Camera Uploads/2015-06-29 11.51.53.jpg’: Invalid argument
cp: cannot stat ‘Camera Uploads/Icon\r’: Invalid argument
cp: cannot stat ‘Cancer’: Invalid argument
cp: cannot stat ‘cardio bad/atria-en-ventrikels.swf’: Invalid argument
cp: cannot stat ‘cardio bad/extreme_90_180.swf’: Invalid argument
cp: cannot stat ‘Cardio databases tools’: Invalid argument
cp: cannot stat ‘Cardiology’: Invalid argument
...
where I keep unexpected browsing through the backup folder.
The challenge here is that the Backups.backupdb is several TBs and seeing that it goes browsing it does not feel good.
No symbolic links
I run
ls -lR /media/masi/eb807ed8-7f45-35f8-a345-9da6692b228a/ |grep Backup
getting
ls: cannot access /media/masi/eb807ed8-7f45-35f8-a345-9da6692b228a/Cancer: Invalid argument
ls: cannot access /media/masi/eb807ed8-7f45-35f8-a345-9da6692b228a/Cardio databases tools: Invalid argument
ls: cannot access /media/masi/eb807ed8-7f45-35f8-a345-9da6692b228a/Cardiology: Invalid argument
drwxr-xr-x 1 root root 7 Jul 8 20:25 Backups.backupdb
ls: cannot open directory /media/masi/eb807ed8-7f45-35f8-a345-9da6692b228a/animations/Embryology/e17_files: Permission denied
^C
so the directory is not a symlink.
Why is extglob except condition broken here by browsing the folder?
Try removing the backslash (I am adding echo for test purposes):
shopt -s extglob
echo cp -r !(Backups.backupdb) /home/masi/Documents/
It works in my environment (GNU bash, version 4.3.30, OS X)
On Windows I am trying to add a Makefile target to remove all files from a specific directory (NOT including subdirectories)...
clean_files:
rm -f Build/*.*
But I get the error: /bin/sh: rm: command not found
Running it from the command line works and running it without the *'s works.
clean_files:
- rm -f Build/*
putting a '-' before a make command will ignore any errors from that command, like
rm: cannot remove `Build/subdir': Is a directory
For removing all files from directory (NOT including sub-directories) consider:
clean_files:
find Build/ -type f -maxdepth 1 -delete