Remove a symlink to a directory
# this works:
rm foo
# versus this, which doesn't:
rm foo/
Basically, you need to tell it to delete a file, not delete a directory. I believe the difference between rm
and rmdir
exists because of differences in the way the C library treats each.
At any rate, the first should work, while the second should complain about foo being a directory.
If it doesn't work as above, then check your permissions. You need write permission to the containing directory to remove files.
In perforce, how to remove a symlink to a directory and add files in the same directory?
There does not seem to be anything preventing this:
C:\Perforce\test\dir>p4 opened
//stream/main/dir#1 - delete default change (symlink)
//stream/main/dir/bar#1 - add default change (text)
//stream/main/dir/foo#1 - add default change (text)
C:\Perforce\test\dir>p4 submit -d "presto"
Submitting change 106.
Locking 3 files ...
delete //stream/main/dir#2
add //stream/main/dir/bar#1
add //stream/main/dir/foo#1
Change 106 submitted.
Cannot remove symbolic link to directory
By putting a trailing slash you are referring to the directory the symlink points to, no longer the symlink itself. Printing the inode number (the number that a path refers to in the file system) shows the difference between dereferencing the symlink and the directory:
$ cd "$(mktemp --directory)"
$ mkdir a
$ stat --format %i a/
9
$ ln --symbolic a b
$ stat --format %i b
10
$ stat --format %i b/
9
This may be related to the fact that a symlink is never a directory, it is always just a file containing a path.
Remove-Item -Recurse -Force can't remove symlinks
The actual CMD equivalent to Remove-Item -Recurse -Force
is:
cmd /c rmdir /s /q foo
as it will delete symlinks also in subdirectories. This seems to be good enough for me.
Removing and adding the same symlink in perforce
To modify a file in a single revision, use p4 edit
instead of p4 add
+ p4 delete
.
Related Topics
Creating a Bootable Iso Image with Custom Bootloader
Git Status Ignore Line Endings/Identical Files/Windows & Linux Environment/Dropbox/Meld
How to Get the Percentage of Memory Free with a Linux Command
Where Does Eclipse Look for Eclipse.Ini Under Linux
Syntax Error Near Unexpected Token 'Then'
How to Modify the Source of Buildroot Packages for Package Development
How Would I Get a Cron Job to Run Every 30 Minutes
Why Doesn't Linux Use the Hardware Context Switch via the Tss
/Usr/Bin/Ld: Cannot Find -Llapack
Prevent Gnome Terminal from Exiting After Execution
Don't Fail Jenkins Build If Execute Shell Fails
Creating Executable Files in Linux
Init Function Invocation of Drivers Compiled into Kernel
How to Edit /Etc/Sudoers from a Script
Check the Open Fd Limit for a Given Process in Linux
Why No Output Is Shown When Using Grep Twice
Write a Bash Shell Script That Consumes a Constant Amount of Ram for a User Defined Time