In a directory, I have 5000 multiple files that contains around 4000 rows with 10 columns in each file containing a unique string 'AT' located at 4th column.
I want to make a script to count how many 'AT' are found in each file, then print this count into a new file at second column. For example below, the 1st column represents the file number and the second column represents the counts. Since I have 5000 multiple files, I expect the first column to be 1....5000.
In the directory, the files are numbered in order and should be printed also in order accordingly into the new file. So in this case, file 1 should be read in first followed by file 2 and so forth until file 5000. How to make it that way?
The small problem was that the files are being read in random order, which is not the way the script should do for the counting. So for example:
Directory:
Newfile:
Column 1, row1 is the first file (1.txt), column 1 row 2 is the second file (2.txt) and goes on until last 5000.txt
Bottleneck is to tell the script to read files inside directory by sorting it out numerically. Then, print this out accordingly into the newfile.
---------- Post updated at 08:03 PM ---------- Previous update was at 07:50 PM ----------
Hi pravin27, thanks.
The script gave the output:
The : symbol is not needed, as this cant be read in into making 2d graph. Also, file extension should not also appear in the first column.
The output expected is:
Thanks again for the time helping me.
-A
---------- Post updated at 08:13 PM ---------- Previous update was at 08:03 PM ----------
Since the expected newfile should be printed out without the suffix *.txt in 1st column, I modified the files in the directory such that:
Directory:
Then i issue this command at console:
Output looks:
How to tell script not have the symbol ":" in between columns 1 and 2. I want to see a space not this symbol ":" in between the two columns.
Hey everyone,
I have a bunch of lines with values in field 4 that I am interested in.
If these values are between 1 and 3 I want it to count all these values to all be counted together and then have the computer print out
LOW and the number of lines with those values in between 1 and 3,... (2 Replies)
I am trying to figure out a way in nawk to 1) get a count of the number of times a value appears in field 1 and 2) count each time the same value appears in field 2 for each value of field 1. So for example, if I have a text file with the following:
grapes, purple
apples, green
squash, yellow... (2 Replies)
Hey Unix gurus,
I would like to count the number occurrences of all the words (regardless of case) across multiple files, preferably outputting them in descending order of occurrence. This is well beyond my paltry shell scripting ability.
Researching, I can find many scripts/commands that... (4 Replies)
Hi,
I have a big file (~960MB) having epoch time values (~50 million entries) which looks like
897393601
897393601
897393601
897393601
897393602
897393602
897393602
897393602
897393602
897393603
897393603
897393603
897393603
and so on....each time stamp has more than one... (6 Replies)
Hi,
I have couple of .txt files (say 50 files) in a folder.
For each file:
I need to get the number of lines in each file and then that count -1 (I wanted to exclude the header.
Then sum the counts of all files and output the total sum.
Is there an efficient way to do this using shell... (7 Replies)
I have 10 appservers and each appserver has 4 jvms . Each of these logs is archived and stored on a nfs directory . For example the files are
/logs/200907/ap1-jvm1.server.log.20090715.gz
/logs/200907/ap2-jvm2.server.log.20090714.gz
/logs/200908/ap1-jvm1.server.log.20090812.gz
I want to... (3 Replies)
Hi,
I have a load of if statements that look for files in a directory, I want to be able to count them up and the total files confirmed in an email? I ahve tried expr but i this does not work and it only reads in the first if and ignores the rest.
Please see script,
#!/bin/ksh
... (2 Replies)
Hi all. If I have a unix directory with multiple files, lets say, I have some with .dat extensions, some with .txt extensions, etc etc.
How in a script would I provide a count of all the different file types (so, the different extensions, I guess) in the directory??
So if I had:
test.dat... (6 Replies)