05-22-2008
command line arg issue with awk
Hi friends,
I am trying to pass input from command line and trying to print that column values. (FYI: I am using ksh) My code goes like this...
#!/bin/sh
column=$1
awk '{print $'$column'}'
I execute using command like this --> ls -l | file_name parameter
Hope I am clear with my problem. The error I am getting is something like this,
Syntax Error The source line is 3.
The error context is
awk >>> ' <<<
awk: 0602-500 Quitting The source line is 3.
I tried even removing quotes, but in vain. please help me.
Thanks in advance,
Divya
10 More Discussions You Might Find Interesting
1. Programming
I try following code under Solaris10,like follows:
int glob = 6;
int main(void)
{
int var;
pid_t pid;
var = 88;
printf("before vfork\n");
if ((pid = vfork()) < 0) {
err_sys("vfork error");
} else if (pid == 0) {
glob++;
var++;
_exit(0);
}
... (1 Reply)
Discussion started by: konvalo
1 Replies
2. Shell Programming and Scripting
I am running a shell script which has the following command
ls *.pdf | wc -l
error: arg list too long
Please post your thoughts on this.. (4 Replies)
Discussion started by: techmoris
4 Replies
3. Shell Programming and Scripting
Hi,
I got a line of text which has spaces in between and it is a long stream of characters. I want to extract the text from certain position. Below is the line and I want to take out 3 characters from 86 to 88 character position. In this line space is also a character. However when using cut... (5 Replies)
Discussion started by: asutoshch
5 Replies
4. Shell Programming and Scripting
Hi,
I am writing a shell script to build Java options dynamically in a variable array and pass them to java.exe. If an option value contains a space, I cannot find a way to get it interpreted correctly. Here is my example:
#!/bin/bash
JAVA_HOME=/opt/jvm/jre1.5.0_18
JAVA_OPTS=("-Xms256m... (4 Replies)
Discussion started by: Romain
4 Replies
5. Shell Programming and Scripting
Hi,
I'm trying to run the following command using sh -c
ie
sh -c "while read EachLine
do
rm -f $EachLine ;
done < file_list.lst;"
It doesn't seem to do anything.
When I run this at the command line, it does remove the files contained in the list so i know the command works
ie... (4 Replies)
Discussion started by: chrispward
4 Replies
6. Shell Programming and Scripting
Hi ,
I am doing some enhancements in an existing shell script. There it used the awk command in a function as below :
float_expr() {
IFS=" " command eval 'awk "
BEGIN {
result = $*
print result
exit(result == 0)
}"'
}
It calls the function float_expr to evaluate two values ,... (1 Reply)
Discussion started by: mady135
1 Replies
7. UNIX for Dummies Questions & Answers
I need a bit of explanation:
LogFile=${LOGS_DIR}/${1}_$$
I know:
- LOGS_DIR is an environment variable
- $$ is the PID
... but what is ${1} ?? Is it another method to access a command line variable, or the job name?
Thanks!
Jon (3 Replies)
Discussion started by: jdorn001
3 Replies
8. Shell Programming and Scripting
Hi All,
I am using the below script which has awk command, but it is not returing the expected result. can some pls help me to correct the command.
The below script sample.ksh should give the result if the value of last 4 digits in the variable NM matches with the variable value DAT. The... (7 Replies)
Discussion started by: G.K.K
7 Replies
9. Shell Programming and Scripting
Hi all,
How to pass the command line argument to a sql file
Script:
#!/bin/ksh
if ] ; then
test.sql
fi
My Sql Informix DB:
echo "select * from table where col1 = 2234
and col2 = '$3'"|dbaccess ddname
But im getting `:' unexpected error (5 Replies)
Discussion started by: Roozo
5 Replies
10. Shell Programming and Scripting
Hi Everyone!
I am facing an issue in running a command line utility from the CRON.
This utility displays IPC statistics on UNIX message queues: The "queue name" and the "count" of messages in the queue.
When running this utility from prompt, it will provide an output on the screen, like the... (4 Replies)
Discussion started by: vai_sh
4 Replies