Sponsored Content
Top Forums Shell Programming and Scripting Getting information from various files Post 302490986 by kristinu on Wednesday 26th of January 2011 12:58:23 PM
Old 01-26-2011
I have file like below. The lines with :0. must be removed except the first one.

Code:
npt02-z30-sr65-rgdt0p50-dc0p006-16x12drw-run1.log:0. Best Value   = 0.0346886
npt02-z30-sr65-rgdt0p50-dc0p006-16x12drw-run1.log:1. Best Value   = 0.034645
npt02-z30-sr65-rgdt0p50-dc0p006-16x12drw-run1.log:2. Best Value   = 0.034645
npt02-z30-sr65-rgdt0p50-dc0p006-16x12drw-run1.log:3. Best Value   = 0.034645
npt02-z30-sr65-rgdt0p50-dc0p006-16x12drw-run2.log:0. Best Value   = 0.0338255
npt02-z30-sr65-rgdt0p50-dc0p006-16x12drw-run2.log:1. Best Value   = 0.0338255
npt02-z30-sr65-rgdt0p50-dc0p006-16x12drw-run2.log:2. Best Value   = 0.0337909
npt02-z30-sr65-rgdt0p50-dc0p006-16x12drw-run2.log:3. Best Value   = 0.0337666
npt02-z30-sr65-rgdt0p50-dc0p006-16x12drw-run2.log:4. Best Value   = 0.0335744
npt02-z30-sr65-rgdt0p50-dc0p006-16x12drw-run3.log:0. Best Value   = 0.0335744
npt02-z30-sr65-rgdt0p50-dc0p006-16x12drw-run3.log:1. Best Value   = 0.0335052
npt02-z30-sr65-rgdt0p50-dc0p006-16x12drw-run3.log:2. Best Value   = 0.0334884
npt02-z30-sr65-rgdt0p50-dc0p006-16x12drw-run3.log:3. Best Value   = 0.0334884
npt02-z30-sr65-rgdt0p50-dc0p006-16x12drw-run4.log:0. Best Value   = 0.0331475
npt02-z30-sr65-rgdt0p50-dc0p006-16x12drw-run4.log:1. Best Value   = 0.0331475
npt02-z30-sr65-rgdt0p50-dc0p006-16x12drw-run4.log:2. Best Value   = 0.0331475
npt02-z30-sr65-rgdt0p50-dc0p006-16x12drw-run5.log:0. Best Value   = 0.0331475
npt02-z30-sr65-rgdt0p50-dc0p006-16x12drw-run5.log:1. Best Value   = 0.0331475
npt02-z30-sr65-rgdt0p50-dc0p006-16x12drw-run5.log:2. Best Value   = 0.0328672
npt02-z30-sr65-rgdt0p50-dc0p006-16x12drw-run5.log:3. Best Value   = 0.0328672

I have coded in csh script like this, but am looking to see if I can improve from this to simplify.
Any suggestions welcome.

Code:
          grep -H "Best Value" $f-run*.log                    \
            | awk '{ if (NR == 1) {                           \
                          chisq = $5 / var_rgdt;              \
                          print i++". "$2" "$3" "$4" "$5      \
                      } else {                                \
                          if ($0 !~ /run[0-9]+\.log:0\. /) {  \
                              chisq = $5 / var_rgdt;          \
                              print i++". "$2" "$3" "$4" "$5  \
                          }                                   \
                      }                                       \
                    }' >> $f.csmis


Last edited by kristinu; 01-27-2011 at 11:40 AM..
 

10 More Discussions You Might Find Interesting

1. Linux

Need to store information relating to certain files

I need to save information relating to certain files that are projected to deleted. I am using find $defPath/archive/sub/subchild -type f -mtime +365 > LOGFILE cat LOGFILE| while read line do ls -l $line | cut -d" " -f 10-15 done But, since cut is cutting columns on space (single... (3 Replies)
Discussion started by: ramu_indian
3 Replies

2. Solaris

To get the hidden files information only

Hi all, I want to get only hidden files(which are start with '.' or '..') information in a current directory. I tried the below command, $ find . -name "^." -exec ls -la '{}' \; but it's not working. Can anyone give me your outputs. Thanks in advance, Raghu. (5 Replies)
Discussion started by: raghu.iv85
5 Replies

3. UNIX for Dummies Questions & Answers

Prepending information from filenames into files

I would like to know how to take information from a filename and place it into the text of the same file. Let's say I have a file called height_2_width_1.txt containing data that is related to a height of 2 and a width of 1, and the text originally looks like this: where these two columns... (13 Replies)
Discussion started by: Scatterbrain26
13 Replies

4. Shell Programming and Scripting

Compare two files and add new information

Hi, I want to compare two fields in two different files and add a corresponding field in a third output file. Something similar to vlookup. Please see the attached input files and the example output file. I want to compare each entry in column 1 in file1 with column 5 in file2. If both the... (6 Replies)
Discussion started by: chabook
6 Replies

5. UNIX for Dummies Questions & Answers

Combining information from Excel files

Hi, I am looking for an AWK or grep script (join will not work here since the data is not sorted) to combine two Excel files that look lke this: Infile1: Georgia Atlanta 1234 1234 Georgia Marrieta 2134 2134 Georgia Scottdale 3414 3414 Georgia Clarkston 2321 2321 Infile2: ... (6 Replies)
Discussion started by: Xterra
6 Replies

6. UNIX for Dummies Questions & Answers

How to copy files with only certain information

I need to copy a list of files in directory and only files with content DUMMY_B should be copy over to a new directory. How can i do that ? Thanks a lot. (2 Replies)
Discussion started by: Alyssa
2 Replies

7. Shell Programming and Scripting

Updated files information

I am using the below script to remove the rows which contains null values in the 3rd column.My requirement here is want to get the filenames which row is removed .please help me. #!/usr/bin/sh Scripts=/ushhquest/data001/Scripts cd /ushhquest/data011/TgtFiles/MonthlyData ls CUSTADDR*.txt >... (4 Replies)
Discussion started by: katakamvivek
4 Replies

8. Shell Programming and Scripting

search information in multiple files and save in new files

hi everyone, im stuck in here with shell :) can you help me?? i have a directory with alot files (genbank files ... all ended in .gbk ) more than 1000 for sure ... and i want to read each one of them and search for some information and if i found the right one i save in new file with new... (6 Replies)
Discussion started by: andreia
6 Replies

9. UNIX for Beginners Questions & Answers

Combine information from 2 files

Hi there, I‘m a newbie in linux (ubuntu) working with several files, some of them containing hundred thousands of lines. I started to extract information out of 2 files, combining them by 1 column: I need a Vlookup-like command that reads sampleID (column 2)(line 2,..line by line) in file 1, looks... (1 Reply)
Discussion started by: Nika
1 Replies

10. UNIX for Beginners Questions & Answers

Matching information from different files

I have a dataset with coordinates of certain points with their names. file1: AAA 5 7 BBB 7 2 CCC 4 4 DDD 4 4 EEE 8 9 FFF 9 9 GGG 4 9 HHH 32 1 III 7 6 JJJ 12 4 KKK 12 3 MMM 15 3The letters represent names of points. In file1 they are unique. I also have file2 with a dataset with... (2 Replies)
Discussion started by: maya3
2 Replies
FSTRACE_CLEAR(8)					       AFS Command Reference						  FSTRACE_CLEAR(8)

NAME
fstrace_clear - Clears the trace log SYNOPSIS
fstrace clear [-set <set name>+] [-log <log name>+] [-help] fstrace c [-s <set name>+] [-l <log name>+] [-h] DESCRIPTION
The fstrace clear command erases the contents of the trace log from kernel memory, but leaves kernel memory allocated for the log. OPTIONS
-set <set name>+ Names the event set for which to clear the associated trace log. The only acceptable value is "cm" (for which the associated trace log is "cmfx"). Provide either this argument or the -log argument, or omit both to clear the "cmfx" log by default. -log <log name>+ Names the trace log to clear. The only acceptable value is "cmfx". Provide either this argument or the -set argument, or omit both to clear the "cmfx" log by default. -help Prints the online help for this command. All other valid options are ignored. EXAMPLES
The following command clears the "cmfx" trace log on the local machine: # fstrace clear PRIVILEGE REQUIRED
The issuer must be logged in as the local superuser "root". SEE ALSO
fstrace(8), fstrace_lslog(8), fstrace_lsset(8) COPYRIGHT
IBM Corporation 2000. <http://www.ibm.com/> All Rights Reserved. This documentation is covered by the IBM Public License Version 1.0. It was converted from HTML to POD by software written by Chas Williams and Russ Allbery, based on work by Alf Wachsmann and Elizabeth Cassell. OpenAFS 2012-03-26 FSTRACE_CLEAR(8)
All times are GMT -4. The time now is 09:38 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy