I have simple script:
#!/bin/sh
column=$1
awk '{print $'$column'}'
When I run:
ls -la | ./Column.sh
I receive:
awk: {print $}
awk: ^ syntax error
Why? All seems correct.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is not very clear what you want the script to do.
The cause of this error is that you are not passing any arguments to the script. As a result
$1is empty.You need to pass the column number that you want to print:
Will print the permissions column which is in column 1.