Tag Archive for 'file'

Perforce: Can’t Clobber Writable File Error

When getting the latest version of a package from a perforce repository I was getting the following error:

Can’t clobber writable file

And of course the file was not being updated. Remember that all the files in perforce are marked as read-only unless opened by the ‘p4 edit’ command. I did a ‘p4 opened’ to check if the file had been opened for edit. It was not. Then I checked the permissions and found that the file was marked as writable.

Simply removing the writable field from the permissions of the file did the trick.

chmod -w <filename>

Now when I did a ‘p4 sync’ the file got updated. Happy.

Popularity: 1% [?]

Find Files Of A Given Name Instantly

Usually when I have to find a file, I use a find and a grep command together – because I still haven’t learnt to use find properly. This is what I do:

find -L . | grep <name>

But this process is usually slow as it traverses the whole directory structure recursively following the symlinks to find all the files and then greps for the name that I need.

Recently I learnt about a faster way of doing the same – use locate to find files of a given name quickly. The command is:

locate <name>

It creates an index of all the files on the system and searches off it when called for. The index is rebuilt (by default) once a day by a cron’d find so results maybe stale by 24 hours.

If locate is not already present on your system, you could install it by:

sudo yum install mlocate

From the SDE Tip – Amazon

Popularity: 1% [?]

Save File With Sudo Permissions In VIM

A lot of time I open a file, make changes and when the time comes to save it realize that I hadn’t sudo’ed it. Learnt that the following command helps:

:w ! sudo tee %

Here’s the reason:

:w tells the vi to save modification of the file

! sudo tee executes the tee command with sudo permissions taking it’s input from :w

% here means the current file name

From the SDE Tip – Amazon

Popularity: 1% [?]