diff options
| author | typebrook <typebrook@gmail.com> | 2020-02-27 16:32:37 +0800 |
|---|---|---|
| committer | typebrook <typebrook@gmail.com> | 2020-02-27 16:32:37 +0800 |
| commit | 00b136155183ae522ca458e540a8cf29bf525e74 (patch) | |
| tree | c6e9d20d5021c95afc7149456d57eb435d808150 /scripts/csv.reorder | |
| parent | 3fa79eb14a4c0244fb2dc4a5b805b7cffaa63770 (diff) | |
update
Diffstat (limited to 'scripts/csv.reorder')
| -rwxr-xr-x | scripts/csv.reorder | 17 |
1 files changed, 0 insertions, 17 deletions
diff --git a/scripts/csv.reorder b/scripts/csv.reorder deleted file mode 100755 index 8a64239..0000000 --- a/scripts/csv.reorder +++ /dev/null | |||
| @@ -1,17 +0,0 @@ | |||
| 1 | #! /bin/bash | ||
| 2 | |||
| 3 | # show each field with index in csv | ||
| 4 | echo -------------- > /dev/tty | ||
| 5 | head -1 < $1 | awk -F',' '{for (i=1; i<=NF; i++) printf $i "_" i " "; print ""}' > /dev/tty | ||
| 6 | echo -------------- > /dev/tty | ||
| 7 | echo > /dev/tty | ||
| 8 | |||
| 9 | read -p "type column numbers by new order, like 3 2 1: " order | ||
| 10 | |||
| 11 | arrange=$(echo $order | sed -r 's/([^ ]+)/$\1/g' | tr ' ' ',') | ||
| 12 | |||
| 13 | cat $1 |\ | ||
| 14 | awk -F',' "BEGIN{OFS=\",\"}{print $arrange}" |\ | ||
| 15 | tee /tmp/csv | ||
| 16 | |||
| 17 | echo "Also copied to /tmp/csv" > /dev/tty | ||