grep and modify


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers grep and modify
# 1  
Old 03-16-2010
grep and modify

if input1 has an expression nouse covert allcolumns in to hashes except 6th column.
ex: abc100 has no use in 3rd row and 4th row and became hashes.

BUT if input1 1st column keys-1st row has no words in 3rd column (ex: def200 (key) and 1st row has no words in 3rd column (no x/x or y/y or others) except nouse. make the whole line into has in this case.
on the other hand abc100 (key-1st row) has words in 3rd column and the lines exists.

Hope I didn't confuse you.
Thanx
Ruby

input1
Code:
abc100    abc    x/x    1    2    3
abc100    abd    y/y    2    3    4
abc100    abd    nouse    nouse    nouse    5
abc100    ade    nouse    nouse    nouse    6
def200    ddd    nouse    nouse    nouse    12
def200    def    nouse    nouse    nouse    23

output
Code:
abc100    abc    x/x    1    2    3
abc100    abd    y/y    2    3    4
#    #    #    #    #    5
#    #    #    #    #    6
#    #    #    #    #    #
#    #    #    #    #    #

# 2  
Old 03-17-2010
MySQL

See the following code:

Code:
sed -r '3,$s/([^ \t]* ){4}/#\t/g'  Input_file

Input file:
Code:
abc100    abc    x/x    1    2    3
abc100    abd    y/y    2    3    4
abc100    abd    nouse    nouse    nouse    5
abc100    ade    nouse    nouse    nouse    6
def200    ddd    nouse    nouse    nouse    12
def200    def    nouse    nouse    nouse    23

Output:
Code:
abc100    abc    x/x    1    2    3
abc100    abd    y/y    2    3    4
#       #       #       #       #       5
#       #       #       #       #       6
#       #       #       #       #       12
#       #       #       #       #       23

You are specifying except 6th column. but in your output last two lines are also having hash (#) for 6th column I am having some confusion on that. you can try with above code.
# 3  
Old 03-17-2010
haa

12 and 23 should be hashes because 1st def200 key doesn't have any values in 3rd column. On contrary 1st abc100 has x/x.

Last edited by ruby_sgp; 03-17-2010 at 03:50 AM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Ed to modify a file --- or not?

Running Oracle Linux 6 (derivative of RHEL 6) Given this snippet of code in a shell script: #-- reset oratab to use 11.2 home for dwdev #-- normally we'd just use sed to do this sort of thing, but that would #-- require permissions that we don't have in the /etc/ directory, so we #-- ... (3 Replies)
Discussion started by: edstevens
3 Replies

2. Shell Programming and Scripting

File modify

Hi All I am getting a file with below pattern - 00150366 05/08/2015 07:14:32 8000186167+++ 50195281000000000371001010903236 800186167+++ 100209000000000 800000018617+++ 50295281000000000371001010900217================================3u4398482344334=432434 00150367 05/08/2015 07:14:32... (7 Replies)
Discussion started by: honey26
7 Replies

3. Shell Programming and Scripting

Inconsistent `ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l`

i have this line of code that looks for the same file if it is currently running and returns the count. `ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l` basically it is assigned to a variable ISRUNNING=`ps -eaf -o args | grep -i sfs_pcard_load_file.ksh |... (6 Replies)
Discussion started by: wtolentino
6 Replies

4. UNIX for Dummies Questions & Answers

How to modify an output?

I have a list XPAR XPAR XPAR , XPAR , , XPAR ,1, XPAR 196 XPAR 95 XPAR 95,77 This has space and tabs on the second row. I would like it to look like XPAR 1, 196, 95, 77 But I always get the below because of the spaces above. , , ,1, 196 95 95,77 I use... (9 Replies)
Discussion started by: priyanka.premra
9 Replies

5. Shell Programming and Scripting

modify awk

awk "BEGIN {if($PERCENT<$WARNING) {print \"OK\" ; exit 0} else if(($PERCENT>=$WARNING) && ($PERCENT<$CRITICAL)) {print \"WARNING\" ; exit 1} else if($PERCENT>=$CRITICAL) {print \"CRITICAL\" ; exit 2} }" how can i... (1 Reply)
Discussion started by: SkySmart
1 Replies

6. Shell Programming and Scripting

modify a format

Hi I have a format that looks like this: #TailType TwoSided #Scale to target True #Target Intensity 100 #Intensities PM/MM #Treatment CEL ./G.CEL #Control CEL ./F.CEL chr1 16 0 chr1 24 0 chr1 32 0.187188 chr1 40 0.14595 chr1 ... (5 Replies)
Discussion started by: kylle345
5 Replies

7. UNIX for Dummies Questions & Answers

Modify Path

Hi, This is certainly a simple question, but I have yet to receive sufficient info concerning it. I am using BASH on a Powerbook G4 running Leopard. - I would like to permanently add a directory to my path. How do I do this? - I understand that I can view my path by: echo $PATH. Is there a... (4 Replies)
Discussion started by: msb65
4 Replies

8. Shell Programming and Scripting

how to modify the value of the variable

Hi I have a variable which holds full path to the file, for example z=/bb/data3/f4222pdb.dta.new I need to remove the extension .new so it would look like z=/bb/data3/f4222pdb.dta Is there a command to do this? This variable is used in the "for" loop later. I am in ksh. Thanks a lot -A (4 Replies)
Discussion started by: aoussenko
4 Replies

9. Shell Programming and Scripting

How to modify the variable

I have a directory name stored in a variable. Does anyone have a piece of code which checks if this stored directory name ends up with the "/" and if it is missing adds it to the same variable. for example I might have A=/bb/data or A=/bb/data/ which needs to be A=/bb/data/ for sure thanks... (5 Replies)
Discussion started by: aoussenko
5 Replies

10. UNIX for Advanced & Expert Users

Modify files

Hi everybody, I have a certine file with lots of number, Which I want to add a " in the begging and at the and of each line. Could anyone tell me how can I do it? Cheers (7 Replies)
Discussion started by: amgo
7 Replies
Login or Register to Ask a Question