Skip to content

Instantly share code, notes, and snippets.

# Bash Scripting - Quoting
Chiunque abbia usato seriamente la Bash si è scontrato almeno una volta (e probabilmente più di una) con problemi legati al quoting.
Uno dei problemi più comuni è la difficoltà nello script che non riescono a gestire casi in teoria semplici come i file con uno spazio nel nome. Quasi come se fosse impossibile gestire dei file con nomi di quel tipo.
In realtà, anche se quasi nessuno sa come, con la Shell è possibile gestire file con nomi contenenti praticamente qualsiasi cosa. Per come è fatta Bash è possibile lavorare con qualsiasi nome di file che il kernel sia in grado di gestire. Quindi, ammesso di conoscere bene le regole del quoting, si può lavorare con problemi sia con i file con nomi contenenti spazi, sia pure con file con nomi contententi le più strane sequenze unicode (dagli emoji della birra a pure alle sequenze unicode non ancora definite nello standard).
Il quoting della shell, se usato correttamente, permette di gestire qualsiasi nome di file. Molti trovano difficolt
@eeichinger
eeichinger / git file change statistics
Created December 9, 2013 10:52
as someone who regularly gets on site with a client and has to quickly work himself into an existing codebase, I found these tools interesting. I stole them from Greg Young's excellent talk "How to get productive on a project in 24h" at http://www.youtube.com/watch?v=KaLROwp-VDY The change rate of modules and files over time is especially intere…
# find the modules/folders with highest number of changes
git rev-list --objects --all | awk '$2' | sort -k2 | uniq -cf1 | sort -rn | head
# find the files with the highest number of changes
git rev-list --objects --all | awk '$2' | sort -k2 | uniq -cf1 | sort -rn |
while read frequency sample path
do
[ "blob" == "$(git cat-file -t $sample)" ] && echo "$frequency\t$path";
done
@sevos
sevos / git-pair
Last active August 3, 2022 10:57 — forked from andrzejsliwa/pair
A script to change pairs
#!/usr/bin/env ruby
# encoding: utf-8
Person = Struct.new(:name, :email) do
def activate
`git config user.name '#{name}'`
`git config user.email '#{email}'`
end
end