Grep a file excluding row with some chars


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Grep a file excluding row with some chars
# 8  
Old 11-04-2010
AWESOME!!! Smilie
Thanks! This is what I'm searching for!

And now please the last thing... How can I redirect the awk output into a file to have all the memory values one each lines?
Sorry, but, as probably you already notice, I'm a newbie! Smilie

EDIT: Ops sorry, read just now the latest post!:
Code:
sed -n '/->/!s/.*GC \([0-9]\+\).*/\1/p' inputfile > outfile

# 9  
Old 11-17-2010
Hey guys,
sorry, I'm back in topic since I need now to change the output of awk command.
The new output should have now the following data (in blue/bold):

Code:
465319.785: [GC 1241647K->402739K(4089472K), 0.0114310 secs]
465406.414: [GC 1241651K->402788K(4089472K), 0.0123300 secs]
465491.070: [GC 1241700K->402769K(4089472K), 0.0138310 secs]
465577.576: [GC 1241681K->402756K(4089472K), 0.0102220 secs]
465664.204: [GC 1241668K->402893K(4089472K), 0.0095680 secs]

Well, I tried with awk based on latest example, but I'm failing because I have extra chars "->" on output.
Code:
$ tail -1 gc.txt | awk -F"[ K]" '/->/{print $4}')
->402893

First of all, may I have the command to extract the above data? Then, is there any good source for awk so in the future I can do it myself? Smilie
# 10  
Old 11-17-2010
How about:
Code:
awk -F"[>K]" '/->/{print $3}'

This User Gave Thanks to Scrutinizer For This Post:
# 11  
Old 11-17-2010
Quote:
Originally Posted by Scrutinizer
How about:
Code:
awk -F"[>K]" '/->/{print $3}'

Thanks it works and it was so simple! Smilie
I'm pretty sure I already tried it (i mean the ">"), but maybe I miss something! Smilie

Well, is there any dummy guide for awk around the net?
# 12  
Old 11-17-2010
Quote:
Originally Posted by Lord Spectre
Thanks it works and it was so simple! Smilie
I'm pretty sure I already tried it (i mean the ">"), but maybe I miss something! Smilie

Well, is there any dummy guide for awk around the net?
Hi probably there is. I myself learned initial awk scripting from a purchased O'Reilly book (sed & awk)...
# 13  
Old 11-17-2010
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell script to split data with a delimiter having chars and special chars

Hi Team, I have a file a1.txt with data as follows. dfjakjf...asdfkasj</EnableQuotedIDs><SQL><SelectStatement modified='1' type='string'><! The delimiter string: <SelectStatement modified='1' type='string'><! dlm="<SelectStatement modified='1' type='string'><! The above command is... (7 Replies)
Discussion started by: kmanivan82
7 Replies

2. Shell Programming and Scripting

Search row by row from one file to another file if match is found print few colums of file 2

this is the requirement list.txt table1 table2 table3 testfile.txt name#place#data#select * from table1 name2#place2#data2#select * from table 10 innerjoin table3 name2#place2#data2#select * from table 10 output name place table1 name2 place table3 i tried using awk (7 Replies)
Discussion started by: vamsekumar
7 Replies

3. UNIX for Dummies Questions & Answers

Grep or sed to search, replace/insert chars!

HI All Im trying to come up with an approach to finding a string, using a portion of that string to insert it on lines starting with the value "GOTO" appending to end of line after removing PT's ( See example below! ) EXAMPLE: 1. I would like to search for the line that starts with "TLAXIS/"... (7 Replies)
Discussion started by: graymj
7 Replies

4. Shell Programming and Scripting

Read row number from 1 file and print that row of second file

Hi. How can I read row number from one file and print that corresponding record present at that row in another file. eg file1 1 3 5 7 9 file2 11111 22222 33333 44444 55555 66666 77777 88888 99999 (3 Replies)
Discussion started by: Abhiraj Singh
3 Replies

5. UNIX for Dummies Questions & Answers

Count on grep for more than two values in a row of fixed length file

I want to get count on number of records in a few folders by running grep command for more than two columns in a row of fixed length file. suppose if i have a fixed length file has 5 columns and I want to see the record counts for country =can and province = bc and time stamp <= 12 feb 2013... (14 Replies)
Discussion started by: princetd001
14 Replies

6. Shell Programming and Scripting

Subtracting each row from the first row in a single column file using awk

Hi Friends, I have a single column data like below. 1 2 3 4 5 I need the output like below. 0 1 2 3 4 where each row (including first row) subtracting from first row and the result should print below like the way shown in output file. Thanks Sid (11 Replies)
Discussion started by: ks_reddy
11 Replies

7. Shell Programming and Scripting

Get a group of line from different file and put them into one file row by row

hi guys, today i'm stuck in a new problem. the title explain more or less but a particular had been omitted. So i'm going to describe below the situation with an example. I have different html files and each of them have a consecutive lines group inside that i want to extract. example: ... (8 Replies)
Discussion started by: sbobotex
8 Replies

8. Shell Programming and Scripting

grep for greater than 12 chars

Hi, is there any way in grep to grep for a certain number of characters? For example I have a list of customerIDs, I want to grep for all greater than 12 characters? (2 Replies)
Discussion started by: borderblaster
2 Replies

9. Shell Programming and Scripting

How to convert C source from 8bit chars to 16bit chars?

I was using the following bash command inside the emacs compile command to search C++ source code: grep -inr --include='*.h' --include='*.cpp' '"' * | sed "/include/d" | sed "/_T/d" | sed '/^ *\/\//d' | sed '/extern/d' Emacs will then position me in the correct file and at the correct line... (0 Replies)
Discussion started by: siegfried
0 Replies

10. Shell Programming and Scripting

Changing the column for a row in a text file and adding another row

Hi, I want to write a shell script which increments a particular column in a row from a text file and then adds another row below the current row with the incremented value . For Eg . if the input file has a row : abc xyz lmn 89 lm nk o p I would like the script to create something like... (9 Replies)
Discussion started by: aYankeeFan
9 Replies
Login or Register to Ask a Question