[FSUG PD] Script per creare link simboloci particolari.
Micky Del Favero
micky a mesina.net
Mar 8 Mar 2011 19:48:43 CET
max_xxv <mauro.soligo a gmail.com> writes:
> Ciao a tutti, prima di tutto scusate il soggetto ma non sapevo come
> descrivere meglio il mio problema.
>
> Ho una cartella con dei file PDF del tipo:
Si chiama directory...
> Ora la mia esigenza è di creare uno script che in una cartella
> dedicata crei un solo link simbolico nella forma AAAAAAAAAAA.pdf per
> ciascun tipo di articolo "AAAAAAAAAAA", ovvero se ci sono 4 file con
> lo stesso codice "AAAAAAAAAAA" e differenti "BBBBBBB" mi dovrà
> generare un solo link ad uno di questi file.
Questo dovrebbe fare ciò che chiedi:
for i in $(ls -1tr *pdf | awk -F\$ '{print $1}' | sort | uniq) ; do \
ln -s $(ls -1tr $i* | head -1) $i.pdf ; done
Es:
micky a grace:/tmp/micky$ ls -gotr *pdf
-rw-r--r-- 1 0 8 mar 19.36 AAAAAAAAAAA$BBBBBB1.pdf
-rw-r--r-- 1 0 8 mar 19.36 AAAAAAAAAAA$BBBBBB2.pdf
-rw-r--r-- 1 0 8 mar 19.36 AAAAAAAAAAA$BBBBBB3.pdf
-rw-r--r-- 1 0 8 mar 19.36 AAAAAAAAAAA$cBBBBB3.pdf
-rw-r--r-- 1 0 8 mar 19.36 AAAAAAAAAAA$cBBBBB2.pdf
-rw-r--r-- 1 0 8 mar 19.36 AAAAAAAAAAA$cBBBBB1.pdf
-rw-r--r-- 1 0 8 mar 19.36 AAAAAAAAAAx$cBBBBB1.pdf
-rw-r--r-- 1 0 8 mar 19.36 AAAAAAAAAAx$cBBBBB2.pdf
-rw-r--r-- 1 0 8 mar 19.36 AAAAAAAAAAx$cBBBBB3.pdf
-rw-r--r-- 1 0 8 mar 19.36 AAAAAAAAAAx$cBBBBB4.pdf
micky a grace:/tmp/micky$
micky a grace:/tmp/micky$ for i in $(ls -1tr *pdf | awk -F\$ '{print $1}' | sort | uniq) ; do ln -s $(ls -1tr $i* | head -1) $i.pdf ; done
micky a grace:/tmp/micky$ ls -gotr *pdf
-rw-r--r-- 1 0 8 mar 19.36 AAAAAAAAAAA$BBBBBB1.pdf
-rw-r--r-- 1 0 8 mar 19.36 AAAAAAAAAAA$BBBBBB2.pdf
-rw-r--r-- 1 0 8 mar 19.36 AAAAAAAAAAA$BBBBBB3.pdf
-rw-r--r-- 1 0 8 mar 19.36 AAAAAAAAAAA$cBBBBB3.pdf
-rw-r--r-- 1 0 8 mar 19.36 AAAAAAAAAAA$cBBBBB2.pdf
-rw-r--r-- 1 0 8 mar 19.36 AAAAAAAAAAA$cBBBBB1.pdf
-rw-r--r-- 1 0 8 mar 19.36 AAAAAAAAAAx$cBBBBB1.pdf
-rw-r--r-- 1 0 8 mar 19.36 AAAAAAAAAAx$cBBBBB2.pdf
-rw-r--r-- 1 0 8 mar 19.36 AAAAAAAAAAx$cBBBBB3.pdf
-rw-r--r-- 1 0 8 mar 19.36 AAAAAAAAAAx$cBBBBB4.pdf
lrwxrwxrwx 1 23 8 mar 19.38 AAAAAAAAAAA.pdf -> AAAAAAAAAAA$BBBBBB1.pdf
lrwxrwxrwx 1 23 8 mar 19.38 AAAAAAAAAAx.pdf -> AAAAAAAAAAx$cBBBBB1.pdf
micky a grace:/tmp/micky$
Ciao, Micky
--
UNIX is basically a simple operating system, but you have to
be a genius to understand the simplicity. -- Dennis Ritchie
Maggiori informazioni sulla lista
fsug-pd