1

I've faced with the problem of using simple shell commands like AWK and print within my sh scripts on my Mac ( the same script works perfect on the Linux). For instance below script which seek for the columns within given input files didn't works

 #! /usr/bin/env bash
input=/Users/Own/Documents/Science/mmgbsa_results/All_decomp2/logs
output=/Users/Own/Documents/Science/mmgbsa_results/All_decomp2/out

for file in $input/*; do
title=$(basename "$file")
#print $title
awk -F’[|]’ '{print $1,$NF}' $file > ${output}/$title
done

output:

awk: no program given

analysis.sh: line 11: ]’: command not found
awk: no program given

analysis.sh: line 11: ]’: command not found
awk: no program given

analysis.sh: line 11: ]’: command not found
awk: no program given

analysis.sh: line 11: ]’: command not found
awk: no program given

analysis.sh: line 11: ]’: command not found
awk: no program given

Here some tests of the shell:

Glebs-MacBook-Pro:All_decomp2 Own$ echo $PATH
/Users/Own/anaconda/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
Glebs-MacBook-Pro:All_decomp2 Own$ awk
usage: awk [-F fs] [-v var=value] [-f progfile | 'prog'] [file ...]
Glebs-MacBook-Pro:All_decomp2 Own$ peint
-bash: peint: command not found
  • What is peint? Can you run an example awk command on one line - Note Linux uses gnu awk and OS X BSD awk so there could be a difference there - also what is line 11? – Mark Feb 4 '15 at 16:04
  • Could you post your $PATH? I tested, and your script works, so, the problem seems to be that can reach awk command. A quick fix can be append the path to the awk, using /usr/bin/awk instead. – jherran Feb 4 '15 at 16:19
  • actually it was Print which has not been worked ( – Gleb Feb 4 '15 at 17:00
  • 3
    Your quotes after the -F in the awk command are wrong, they need to be ' – 0942v8653 Feb 4 '15 at 17:46
  • 0942v8653 has the right idea. Make sure you're using a text editor to write your scripts, not a word processor. – glenn jackman Feb 5 '15 at 18:50

You must log in to answer this question.

Browse other questions tagged .