Jump to content


How to delete a set of files a.x.* and keep a.x?

p4 delete wildcard

  • Please log in to reply
2 replies to this topic

#1 bscriver

bscriver

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 30 September 2014 - 06:51 PM

I have a set of files:
a.x, a.x.a, a.x.b, a.x.c, ...

I would like to delete all of the files except a.x.

I tried:
* p4 delete a.x.* <-- Deleted a.x as well
* p4 delete a.x.... <-- Didn't match any files

Is there a way to represent this trivially on the command line?

#2 P4Shimada

P4Shimada

    Advanced Member

  • Members
  • PipPipPip
  • 831 posts

Posted 01 October 2014 - 12:26 AM

Hi,

Use regular expressions (i.e. awk, sed, grep) to get all of the files except 'a.x' and then pipe it to the delete command using the global -x flag:

[reg expression command] | p4 -x - delete

You can see examples of this in these Knowledge Base articles below:

    http://answers.perfo...-Directory-Tree

    http://answers.perfo...s-from-Commands



Global options:

http://www.perforce....al.options.html

#3 P4Sam

P4Sam

    Advanced Member

  • Members
  • PipPipPip
  • 484 posts
  • LocationSan Francisco, CA

Posted 01 October 2014 - 08:38 PM

View Postbscriver, on 30 September 2014 - 06:51 PM, said:

I have a set of files:
a.x, a.x.a, a.x.b, a.x.c, ...

I would like to delete all of the files except a.x.

I tried:
* p4 delete a.x.* <-- Deleted a.x as well
* p4 delete a.x.... <-- Didn't match any files

Is there a way to represent this trivially on the command line?

Use quotes (this might depend on your shell):

C:\test\local\client\forum\d>p4 delete -n a.x.*
//depot/forum/d/a.x#1 - opened for delete
//depot/forum/d/a.x.a#1 - opened for delete
//depot/forum/d/a.x.b#1 - opened for delete
//depot/forum/d/a.x.c#1 - opened for delete

C:\test\local\client\forum\d>p4 delete -n "a.x.*"
//depot/forum/d/a.x.a#1 - opened for delete
//depot/forum/d/a.x.b#1 - opened for delete
//depot/forum/d/a.x.c#1 - opened for delete

Without the quotes, the shell will expand a.x.* into a list of local files, and in this case it considers that list to include a.x.  (I'm guessing this is a Windows-ism and has something to do with Windows filenames always having an implicit .something at the end.)  If you tell the shell to leave it alone by putting it in quotes, the wildcard is processed by Perforce instead.





Also tagged with one or more of these keywords: p4, delete, wildcard

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users