Quantcast
Channel: Removing certain file types that do not contain the hostname in the file name - Ask Ubuntu
Viewing all articles
Browse latest Browse all 2

Removing certain file types that do not contain the hostname in the file name

$
0
0

I am doing a file deployment for multiple machines per site, so it is much easier for me to zip all the files once and deploy to every machine. However I would like to remove the config for all the other PC's.

The zip contains various generic files, and also a specific config for each machine.

For example a less of the zip would provide:

generic1.xjson
generic2.xjson
generic3.xjson
generic1.yjson
generic2.yjson
PC-1-1.json
PC-1-2.json
PC-1-3.json

So I am looking to remove every PC-1-*.json that does not contain the PC's hostname.

(the PC hostnames are always exactly PC-1-1, etc.)

I was trying to do something along the lines of:

ls -1 | grep -v *$hostname* | xargs -0 rm *PC-*-*.json

This would remove all the files including the one for the current hostname.

Looking for what I have wrong in this, or if there is a better way of doing this function.


Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>