Thanks guys. I have played with all the methods you suggested but it does not seem to give me any output. It works without errors - but just doesn't give output. I should have said I am using the bash shell - could some of these commands not be working properly on my setup? Is there a way I can set it up so it works as you have it.
If it helps - this is the message it gives me for one of the options that doesn't work.
Once again thanks in advance for looking at this and so quickly - its really appreciated.
Charlie
What system are you using? If it is a Solaris system, try using /usr/xpg4/bin/awk or nawk instead of /usr/bin/awk.
If it is a Solaris system, there is also a good chance that nextfile isn't supported, but that should have generated a clearer error message. Have you tried the other form:
Hi Guys, thanks again for swift responses on this. I managed to solve my problem - so thought I would share - feel free to comment. Also have another question. So just for everyone's benefit in the code below I am
1. Doing recursive find of the .txt files
e.g. /folder1/folder2/folder3/a.txt
2. Pulling out the first row of each of the .txt files
e.g. from a.txt take only first row abc|def|efg
3. Count number of | strings into temp2 variable
4. Count number of / strings from the path name into temp3
5. I only want to output paths which have a set number of / strings (only 9 and 10)
SO HERE'S THE NEW QUESTION:
so for the check on the number of / string I have the OR clause but what actually happens is that it finds paths which have 10 strings it it and outputs them but does not look at any with 9 in them. equally if I swap the code around it find the paths with 9 in them but does not look at any with 10. Is there a better way to do this other than split up the if statement?
Last edited by Scott; 12-04-2012 at 08:00 AM..
Reason: Please use code tags and less formatting
Does your find provide the -mindepth and -maxdepth options? That would help in the first place. If it does not, why don't you filter find's output before reading it into the i variable?
I have a large dataset with following structure;
C 0001 Carbon
D SAR001 methane
D SAR002 ethane
D SAR003 propane
D SAR004 butane
D SAR005 pentane
C 0002 Hydrogen
C 0003 Nitrogen
C 0004 Oxygen
D SAR011 ozone
D SAR012 super oxide
C 0005 Sulphur
D SAR013... (3 Replies)
I have a file example.txt as follows :SomeTextGoesHere
$$TODAY_DT=20140818
$$TODAY_DT=20140818
$$TODAY_DT=20140818I need to automatically update the date (20140818) in the above file, by getting the new date as argument, using a shell script.
(It would even be better if I could pass... (5 Replies)
Hi,
Need some help...
I want to execute sequence commands, like below
test1.sh
test2.sh
...etc
test1.sh file will generate log file, we need to search for 'complete' string on test1.sh file, once that condition success and then it should go to test2.sh file, each .sh scripts will take... (5 Replies)
Is there a way to use the find command to recursively scan directories for files greater than 1Gb in size and print out the directory path and file name only?
Thanks in advance. (6 Replies)
Tricky one:
I want to do several things all at once to blow away a directory (rm -rf <dir>)
1) I want to find all files recursively that have a specific file extension (.ver) for example.
2) Then in that file, I want to grep for an expression ( "sp2" ) for example.
3) Then I want to... (1 Reply)
Hi all,
I need to get the latest file. I have found this command "ls -lrt" that is great but not recursive.
Can anyone help?
Thanx by advance. (7 Replies)
Hi,
I am trying to grep a particular string from the files of 2 different servers without copying and calculate the total count of its occurence on both files.
File structure is same on both servers and for reference as follows:
27-Aug-2010... (4 Replies)
Hi,
I have to grep a word 'XYZ' from 900 files ( from 2007 till date), take its count month wise. The output should display month, count , word 'XYZ' .
I tried searching the forum for solution but could find any.
I would apprieciate if any one can help me asap ....
Many Thanks:) (12 Replies)
Hi
My files is like
a|test|s|
b|test2 | n|
c|ggg|v|
i want to count the no of lines which is ending with "|" ...
Please let me know how can it be done.
Thanks,
Arun (4 Replies)
Hey Guyz I have a requirement something like this..
a part of file name, date of modification of that file and a text is entered as input.
like
Date : 080206 (MMDDYY format.)
filename : hotel_rates
text : Jim
now the file hotel_rates.ZZZ.123 (creation date is Aug 02 2006) should be... (10 Replies)