El awk
es una buena herramienta para este trabajo:
awk 'NR==FNR{a[$1]=$2;next}a[$1]{print $2,a[$1]}' file1 file2
Cuando se lee el primer archivo (FN==FNR
), complete la matriz a
con valores de la segunda columna e indexe desde la primera columna. Luego, cuando se procese el segundo archivo, imprima su segunda columna y la segunda columna del archivo1.
Salida:
aligator 23
panda 52
bear 36
shark 25
Я использовал Notepad++ в Windows, поэтому мне пришлось запустить
sed -i -e 's/\r$//' /etc/start.sh
для замены окончаний строк Windows.
The ^M is a carriage return character. Linux uses the line feed character to mark the end of a line, whereas Windows uses the two-character sequence CR LF. Your file has Windows line endings, which is confusing Linux.
Ответ -Тема :https://askubuntu.com/questions/304999/not-able-to-execute-a-sh-file-bin-bashm-bad-interpreter