AWK File Traversal


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting AWK File Traversal
# 8  
Old 01-23-2009
Quote:
Originally Posted by beefeater267
Hi...

Thanks for clarifying... however , i get an error:

./scr: line 11: syntax error near unexpected token `|'
./scr: line 11: `for file in `find $ARCHIVE -type f` | \'
it would help if you'd shown the code Smilie
I fixed MY post (not Jim's - you're trying Jim's).
# 9  
Old 01-23-2009
Thanks for your help. My mistake.... your code works!
# 10  
Old 01-23-2009
So, now I want to print something before the results like : total names: xx .......... how can i do that?
# 11  
Old 01-23-2009
Code:
#!/bin/ksh

ARCHIVE=/home/directory

echo 'Total Names:'
awk '
  FNR==4 { 
     Names[substr($0,14)]
  }
  END {
      for( i in Names)
          print i
  }
' $(find $ARCHIVE -type f) | sort

# 12  
Old 01-23-2009
Hey

I'm sorry I should have clarified..... I want: Total Names: (number of names)
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Awk: Print count for column in a file using awk

Hi, I have the following input in a file & need output as mentioned below(need counter of every occurance of field which is to be increased by 1). Input: 919143110065 919143110065 919143110052 918648846132 919143110012 918648873782 919143110152 919143110152 919143110152... (2 Replies)
Discussion started by: siramitsharma
2 Replies

2. Shell Programming and Scripting

file traversal

Hi, I have to get some value of the from a flat file and my file format is like this. ABC DEF HIJ=1 XYZ xyz HIJ=2 So i need to make sure i get all the value of HIJ under XYZ and not ABC. (4 Replies)
Discussion started by: nidhink
4 Replies

3. Shell Programming and Scripting

awk command to compare a file with set of files in a directory using 'awk'

Hi, I have a situation to compare one file, say file1.txt with a set of files in directory.The directory contains more than 100 files. To be more precise, the requirement is to compare the first field of file1.txt with the first field in all the files in the directory.The files in the... (10 Replies)
Discussion started by: anandek
10 Replies

4. Shell Programming and Scripting

Parse file using awk and work in awk output

hi guys, i want to parse a file using public function, the file contain raw data in the below format i want to get the output like this to load it to Oracle DB MARWA1,BSS:26,1,3,0,0,0,0,0.00,22,22,22.00 MARWA2,BSS:26,1,3,0,0,0,0,0.00,22,22,22.00 this the file raw format: Number of... (6 Replies)
Discussion started by: dagigg
6 Replies

5. UNIX for Advanced & Expert Users

need help in file traversal via FTS(3)

Hi friends, I was trying to traverse a file using FTS(3) . this is the code below.. but I am getting segmentation error in the line fts_read(...) , anybody have any idea , why it is? Please, help me. Thanks in advance.... (2 Replies)
Discussion started by: jack85
2 Replies

6. Shell Programming and Scripting

Creating breadth traversal binary tree

I almost have the entire script written. however the problem is how would i assign the global variable to terminate the process from the bottom up to ensure the child terminates so the parent can. ex. I am proccess 1 I am proccess 2 etc Here is the code $ cat tree.c ... (3 Replies)
Discussion started by: slurpeyatari
3 Replies

7. UNIX for Dummies Questions & Answers

Command line traversal

What is a key, if on command line I have to trverse left & right word by word, instead of character by character? (7 Replies)
Discussion started by: videsh77
7 Replies
Login or Register to Ask a Question