11/08/2019

linux rename all the files with special characters

This one just strip the special characters from filenames
for file in *; do mv "$file" `echo $file | tr -cd '.A-Za-z0-9_-'` ; done
Námásté Egész-ség.mkv --> NmstEgsz-sg.mkv
put echo after ; do to test before, like:
for file in *; do echo mv "$file" `echo $file | tr -cd '.A-Za-z0-9_-'` ; done


https://unix.stackexchange.com/questions/216659/how-to-rename-all-files-with-special-characters-and-spaces-in-a-directory/218291

4/12/2019

sumcol

#!/bin/csh -f
if ($#argv != 2) then
echo "you must give exactly two parameters, first for name of file and second for column number"
else
set file = $argv[1]
set column = $argv[2]

set sumcol = `awk -v col=$column '{ sum+=$col} END {print sum}' $file `
set max = `awk -v col=$column 'NR==1{max = $col + 0; next} {if ($col > max) max = $col;} END {print max}' $file `
set min = `awk -v col=$column 'NR==1{min = $col + 0; next} {if ($col < min) min = $col;} END {print min}' $file `
#awk '{ sum+=$("$column")} END {print sum}'


echo ""
/bin/echo -e "Sum of column $column of file '$file' is \033[0;31m "$sumcol" \033[0m "
echo ""
/bin/echo -e "Max of column $column of file '$file' is \033[0;34m "$max" \033[0m "
echo ""
/bin/echo -e "Min of column $column of file '$file' is \033[0;35m "$min" \033[0m "
echo ""

endif