dimanche 1 mars 2015

Edit a file via a script yet maintain the osx tags


On OSX you can have tags which allows you to identify different categories of files. Here are two text files with different tags when viewed in Finder:


enter image description here


I have a large number of these files and have written a bash script to make several edits on these files. So, for instance I do:



$ sed 's/old text/new text/' file1.txt > /tmp/foo.txt
$ cp -p /tmp/foo.txt file1.txt


in which case I get the desired file content but loose the tags:


enter image description here


Question: How do I copy the tags from the original file to the edited file?



Aucun commentaire:

Enregistrer un commentaire