Sponsored Content
Top Forums UNIX for Dummies Questions & Answers [Solved] Syntax error for awk in a loop Post 302648745 by A-V on Wednesday 30th of May 2012 10:09:42 AM
Old 05-30-2012
Hammer & Screwdriver [Solved] Syntax error for awk in a loop

can some one please tell me what is the problem with my syntaxSmilie

I have 100 files in one folder
1. want to read each of the line by line
2. calculate their number of the words between the first word and the last word of each line
3. create file for each file with number of words between them instead of words for each line

Code:
FILES="word/*"
for X in "$FILES"
do	
	awk '{print NF-2}' $X > count/$X-new.txt 
done

and it gives the error
Quote:
bash: count/word/*-new.txt: No such file or directory
but some who this is not working and I dont understand where the problem is Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

syntax error in while loop

Hi, I have the following script (compile_mercury) and I get this error: I have no idea why...and I have written this script completely in linux (bash) and not in windows. **************** ./compile_mercury: line 136: syntax error near unexpected token `done' ./compile_mercury: line 136:... (1 Reply)
Discussion started by: habzone2007
1 Replies

2. Shell Programming and Scripting

Problems with syntax in a loop (AWK)

Hi guys, I'm trying to loop through a number of files that is set by whatever is in a field. eg. The idea is to split FILELIST down into fields, it could contain 1 - 999 fields and it's bar delimited. I thought simple, count the number of fields in the field and then loop... (1 Reply)
Discussion started by: Peejay
1 Replies

3. Shell Programming and Scripting

Syntax error: Bad for loop variable

Hi Can any one help, I'm trying to run a script that beeps out the ip address from the PC internal speaker with the following script. It keeps throwing the error "Syntax error: Bad for loop variable" on line 16. I know its picking up the IP ADDRESS correctly. Any ideas on whats wrong. I'm... (3 Replies)
Discussion started by: dman
3 Replies

4. Shell Programming and Scripting

Syntax error: Bad for loop variable

I'm getting an error while running this script. Need help. set -x verbose #echo on clear #clear the screen USERNAME="bbb" PASSWORD="password" SERVER="192.168.1.100" WAIT_TIME=300 FILE_PATH="/home/users/xxx/MMM" # local directory to pickup *.dat file REMOTE_PATH="/Drop_off/xxx/yyy" #... (17 Replies)
Discussion started by: clgz2002
17 Replies

5. Shell Programming and Scripting

IF loop syntax error

I am trying to run a menu option though IF loops. I keep getting errors not allowed the menu to be processed correctly. Currently it will accept the first 2 statements but then crash on the 3rd. The 2nd and 3rd have the same syntax, so I do not understand why it breaks. #!/bin/bash while... (4 Replies)
Discussion started by: Ironguru
4 Replies

6. Shell Programming and Scripting

[Solved] 0403-057 Syntax error `<' is not matched

curr_time=`date +%Y%m%d%H%M` curr_date=`date +%Y%m%d` zero=0 script_path="/home/wccuser1/wcc/Scripts/bulk_file_ftp" file_dir="/home/wccuser1/wcc/Bulk_Files" todays_file_count=`ls -ltr | grep $curr_date | awk '{print $9}' | wc -l` todays_file=`ls -ltr | grep $curr_date | awk '{print $9}'` if... (5 Replies)
Discussion started by: gagandeep
5 Replies

7. Shell Programming and Scripting

[Solved] 0403-057 Syntax error for if statement

I am getting the following error when I am running a script in ksh when trying to execute an if statement comparing two numerical values tstmb.sh: 1.5321e+08: 0403-057 Syntax error Below is my code snippet. #!/bin/ksh set -x TODAY=$(date +%y%m%d) for file in $(ls -rt *.log | tail... (11 Replies)
Discussion started by: kiran1112
11 Replies

8. Shell Programming and Scripting

[Solved] FOR loop / IF statement returning error

The code at the bottom is a simplified example of what we have. If I use the following: && echo "echo failed" $? returns 1 When I use if ; then echo "echo failed" ; fi $? returns 0 Does anyone know what's wrong with this? Using AIX 6.1 and KSH for NUM in 1 2 3 do ... (5 Replies)
Discussion started by: jfxdavies
5 Replies

9. Shell Programming and Scripting

[Solved] While loop error when add sqlplus command

Hi gurus, I hit a block when write the script. I need do while loop, in the loop I have code below. sqlplus -s abc/abc@abc <<EOF spool testwhile select * from dual; spool off exit; EOF when I run script with only this code, it works fine. if I add code as below: #!/bin/ksh ... (5 Replies)
Discussion started by: ken6503
5 Replies

10. UNIX for Dummies Questions & Answers

Syntax error in for loop

I am using simple for loop, but getting syntax error when I run the code code #!/bin/ksh pls enter number read n for(i=1; i<=n; i++) do echo $i done syntax error + pls enter number + read n (5 Replies)
Discussion started by: stew
5 Replies
POLISH(5)							      Debian								 POLISH(5)

NAME
polish - a list of Polish words DESCRIPTION
/usr/share/dict/polish is an ASCII file which contains an alphabetic list of words, one per line. FILES
/etc/dictionaries-common/words is a symbolic link to a /usr/share/dict/<language> file. /usr/share/dict/words is a symbolic link to /etc/dictionaries-common/words, and is the name by which other software should refer to the system word list. See select-default-wordlist(8) for more information. The directory /usr/share/dict can contain word lists for many languages, with name of the language in English, e.g., /usr/share/dict/french and /usr/share/dict/danish contain respectively lists of French and Danish words if they exist. Such lists should be coded using the UTF-8 character set encoding. SEE ALSO
ispell(1), select-default-wordlist(8), and the Filesystem Hierarchy Standard. HISTORY
The words lists are not specific, and may be generated from any number of sources. The system word list used to be /usr/dict/words. For compatibility, software should check that location if /usr/share/dict/words does not exist. AUTHOR
Word lists are collected and maintained by various authors. Debian Project March 29th, 2011 POLISH(5)
All times are GMT -4. The time now is 08:18 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy