Helpful Perforce One-liners --------------------------- ### About This Project The page contains a list of handy single-line Perforce scripts. Most of these can easily be converted into custom tools to run from the Perforce GUIs. If you have a favorite that's not listed here, please share it! The "shell command" one-liners will run in most generic shells, including the standard Windows **cmd** prompt, but most require a set of CLI tools that are only standard on Unix. The free [Cygwin toolkit](http://www.cygwin.com) is a popular way to get similar versions of these tools on Windows. The [Powershell](http://en.wikipedia.org/wiki/Windows_PowerShell) one-liners do not require Unix tools. The [px](px "wikilink") commands use an extended command-line client. ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- {{ OnelinerEntry | description=Find all files containing a given expression. (Obsoleted by [p4 grep](http://www.perforce.com/perforce/doc.current/manuals/cmdref/grep.html).)| shellcmd=p4 print PATH | grep -e EXPR -e "\^//" | grep -B1 -e EXPR | powershellcmd=p4 print PATH | select-string EXPR,\^//\\w | %{if(\$\_ -match "\^//\\w"){\$f=\$\_}else{if(\$f){\$f;\$f=0};\$\_}} p4 print PATH | select-string EXPR,\^//\\w | %{if(\$\_ -match "\^//\\w"){\$f=\$\_}else{\$\_}} | select @{n="file";e={\$f}},@{n="match";e={\$\_}} | script=//guest/sam\_stafford/scripts/p4find.bat | contributor=Sam Stafford, Philip Kania}} ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [Category: Perforce](Category:_Perforce "wikilink") [Category: Shell](Category:_Shell "wikilink")