Created
February 25, 2015 16:57
-
-
Save antoinecourtin/de864076e9564b3f08ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
dir=antoine | |
mkdir -p $dir # creation repertoire | |
(echo "antoine courtin pierre" | |
echo "antoine courtin toto" | |
echo "b d e") > $dir/test | |
cut -f1-2 -d' ' $dir/test | | |
sort | | |
uniq -c | | |
sed -e 's#^ *##' > $dir/test.count | |
cat $dir/test.count | | |
while read line | |
do | |
var1=`echo $line | cut -f2- -d' '` | |
list=`grep "$var1" $dir/test \ | |
| tr '\n' ' ' \ | |
| sed -e 's# $#\n#' \ | |
-e "s#$var1##g" \ | |
| tr -s ' ' \ | |
| sed -e 's#^ ##' \ | |
| tr ' ' ','` | |
echo "$line \"$list\"" | |
done | tr ' ' ',' > $dir/test.final |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment