Is it possible to use a P4 command to `Mark for Delete` every file that is "missing"? - perforce

Say I had checked in the files:
a.txt
b.txt
c.txt
I checked them all out so that I could mass edit them by dumping files from another folder:
cp -R folder-one/* folder-two/
The result is:
a.txt (updated)
b.txt (deleted)
c.txt (no changes)
Now I Revert Unchanged Files and intend to submit:
a.txt (updated)
b.txt (deleted)
But I can't because now b.txt is "missing".
Is it possible to use a P4 command to Mark for Delete every file that is "missing"?

Easiest fix is just to revert all of the files that you've opened (with the -k flag so you keep your local changes) and let reconcile figure it out from square one:
p4 revert -k ...
p4 reconcile ...

Related

In linux, how to save only the command into file without output

I just want to save only the command into file, without the long output. For example, i type ls, terminal output a.txt b.txt, if i type ls > command.txt, the content of command.txt will be
a.txt
b.txt
command.txt
But what i want is :
ls
Can we achieve this ?
All shells store the history of commands run in dotfiles in the home directory.
Assuming you're using bash, i think you should be looking at the ~/.bash_history file

Comparing 2 files in linux for different word

I have two files like below
file1 has the below words
word23.cs
test.cs
only12.cs
file 2 has the below words
word231.cs
test.cs
only12.cs
The above words might change, And now i need to compare the two files using script or linux command to get the different word , i need to compare the file2 with file1 and need to get the output as word23.cs
Thank you
Use the "diff" command to compare 2 files:
$ diff a.txt b.txt
Or, for a unified diff:
$ diff -u a.txt b.txt
Use -u0 for a unified diff without context.
You can use comm, diff or cmp command to find different word from files.
Also this trick can work with a grep command as follows
grep -Fwf file1 file2

How do I split a large changelist in P4

I have a very large changelist (~40,000 files) and I need to split it into several smaller changelists so I can view the files contained. I am aware that I can adjust my p4 preferences to show more files in a changelist, but I need to run commands against the files in the changelist, and when I run the command it hangs and doesn't complete after 18 hours.
I'm running the 2012.2 P4 server.
The command I'm running is:
C:>p4 -u some_user -c some_client revert -k -c 155530 //...
Thanks
If you want to move files into a separate changeset, you could do:
p4 reopen -c default //some/subdirectory/...
p4 change
The above would move a portion of the files into the "default" changeset and then create a new changeset from them. Or, if you have another changeset to use already, you could of course do:
p4 reopen -c NEW_CLN //some/subdirectory/...
directly.
If the files you want to split out aren't nicely contained within a subdirectory, a more general approach would be to do:
p4 -ztag opened -c OLD_CLN | grep depotFile | cut -d ' ' -f 3 > files.txt
to get a list of files opened in that changeset. Then edit that file so that only files you want to remove from the changeset are listed, and then do:
p4 -x files.txt reopen -c NEW_CLN
The above calls p4 reopen -c NEW_CLN using each of line from files.txt as an argument.

How can i rename a filename from vim?

vim .
Now I get the list of directory and files.
Now how can I rename a filename from that list of files?
In command mode:
:E opens up the directory view.
R renames the selected file. The shortcuts are listed above the listing.
If you use vim . you can rename with R (because it is the very same thing as above).
You can use qmv (on debian-like systems apt-get install renameutils) which does exactly that and it honours your system default editor (VISUAL, EDITOR, execvp("editor"))
qmv *.cs
opens up an editor, you can %s///g what you like, use C-a / C-x to increment/decrement numbers - in short everything you ever wanted to. You can also rename in circular fashion, e.g.
a.txt b.txt
b.txt a.txt
or
a.txt b.txt
b.txt c.txt
c.txt a.txt
etc.
You can use the external mv command like this:
:! mv oldfile newfile

How to store result of diff in Linux

How to get the result on another file after applying diff to file A.txt and B.txt.
Suppose File A.txt has:
a
b
c
File B.txt has:
a
b
on running
diff A.txt B.txt
It gives result as c, but how to store it in a file C.txt?
The diff utility produces its output on standard output (usually the console). Like any UNIX utility that does this, its output may very simply be redirected into a file like this:
diff A.txt B.txt >C.txt
This means "execute the command diff with two arguments (the files A.txt and B.txt) and put everything that would otherwise be displayed on the console into the file C.txt". Error messages will still go to the console.
To save the output of diff to a file and also send it to the terminal, use tee like so:
diff A.txt B.txt | tee C.txt
tee will duplicate the data to all named files (only C.txt here) and also to standard output (most likely the terminal).
Using > you can redirect output to a file. Eg:
diff A.txt B.txt > C.txt
This will result in the output from the diff command being saved in a file called C.txt.
Use Output Redirection.
diff file1 file2 > output
will store the diff of file1 and file2 to output
There are some files that diff may not do well with the output, like block special files, character special files, and broken links. The output due to differences with these may go to standard error.
Interestingly, when I redirected standard error, I still missed some things:
diff -qr <DirA> <DirB> 2>&1 > mydiff.txt
The only way to see the results of everything was to:
diff -qr <DirA> <DirB> |tee mydiff.txt
I was comparing the results of a live-cd mounted directory after copying to an external HD

Resources