win2008R2 using gnu grep/awk to find only the I instance out of the command

 
Thread Tools Search this Thread
Special Forums Windows & DOS: Issues & Discussions win2008R2 using gnu grep/awk to find only the I instance out of the command
# 1  
Old 06-26-2012
win2008R2 using gnu grep/awk to find only the I instance out of the command

Ok, running tsm on 2008R2, and I have the gnu awk and grep installed...I want to only capture inactive (I) files inside of the backup...I can get this to work on linux, but because windows interprets " ' ` differently, i can't get it to print out right...Here's what I have:

so basically here's the command

Code:
F:\Program Files\Tivoli\TSM\baclient>dsmc q backup f:\* -subdir=yes -ina | grep "0  B" | awk "$1<=0"



             0  B  06/11/2012 13:55:09             STANDARD             A  \\virttsm\f$\db001
             0  B  06/11/2012 16:08:16             STANDARD             A  \\virttsm\f$\FILES
             0  B  06/11/2012 13:03:39             STANDARD             I  \\virttsm\f$\FILES
             0  B  06/11/2012 13:55:09             STANDARD             A  \\virttsm\f$\db001\SERVER1
             0  B  06/11/2012 13:55:09             DEFAULT              A  \\virttsm\f$\db001\SERVER1\SQLCRT.FLG
             0  B  06/11/2012 16:08:16             DEFAULT              A  \\virttsm\f$\FILES\dsmc
             0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888
             0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy
             0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (10)
             0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (11)
             0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (12)
             0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (13)
             0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (14)
             0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (15)
             0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (16)
             0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (17)
             0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (18)
             0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (19)
             0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (2)
             0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (20)
             0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (21)
             0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (3)
             0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (4)
             0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (5)
             0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (6)
             0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (7)
             0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (8)
             0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (9)

then inside of unix i would just print where field 6 == I, any ideas inside of windows so that I only capture the I column

thxs in adv

Moderator's Comments:
Mod Comment Code tags for code please.

Last edited by Corona688; 06-26-2012 at 03:46 PM..
# 2  
Old 06-26-2012
Code:
awk '$1 >= 0 { print $6 }'

# 3  
Old 06-26-2012
doesn't work, but here's more

Ok, so the first command gives me this:
Code:
0  B  06/11/2012 13:55:09             STANDARD             A  \\virttsm\f$\db001
 0  B  06/11/2012 16:08:16             STANDARD             A  \\virttsm\f$\FILES
 0  B  06/11/2012 13:03:39             STANDARD             I  \\virttsm\f$\FILES
 0  B  06/11/2012 13:03:39             STANDARD             I  \\virttsm\f$\FILES1
 0  B  06/11/2012 13:03:39             STANDARD             I  \\virttsm\f$\FILES2
 0  B  06/11/2012 13:03:39             STANDARD             I  \\virttsm\f$\FILES3
 0  B  06/11/2012 13:03:39             STANDARD             I  \\virttsm\f$\FILES4
 0  B  06/11/2012 13:55:09             STANDARD             A  \\virttsm\f$\db001\SERVER1
 0  B  06/11/2012 13:55:09             DEFAULT              A  \\virttsm\f$\db001\SERVER1\SQLCRT.FLG
 0  B  06/11/2012 16:08:16             DEFAULT              A  \\virttsm\f$\FILES\dsmc
 0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888
 0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy
 0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (10)
 0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (11)
 0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (12)
 0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (13)
 0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (14)
 0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (15)
 0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (16)
 0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (17)
 0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (18)
 0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (19)
 0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (2)
 0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (20)
 0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (21)
 0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (3)
 0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (4)
 0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (5)
 0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (6)
 0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (7)
 0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (8)
 0  B  06/11/2012 13:03:39             DEFAULT              A  \\virttsm\f$\FILES\file_1888 - Copy (9)

Then what i need with the additional awk parameters is the following:
Code:
0  B  06/11/2012 13:03:39             STANDARD             I  \\virttsm\f$\FILES1
0  B  06/11/2012 13:03:39             STANDARD             I  \\virttsm\f$\FILES2
0  B  06/11/2012 13:03:39             STANDARD             I  \\virttsm\f$\FILES3
0  B  06/11/2012 13:03:39             STANDARD             I  \\virttsm\f$\FILES4
etc


Last edited by nextreme; 06-26-2012 at 04:21 PM..
# 4  
Old 06-26-2012
output that I need to get would be this:
Code:
0  B  06/11/2012 13:03:39             STANDARD             I  \\virttsm\f$\FILES1
0  B  06/11/2012 13:03:39             STANDARD             I  \\virttsm\f$\FILES2
0  B  06/11/2012 13:03:39             STANDARD             I  \\virttsm\f$\FILES3
0  B  06/11/2012 13:03:39             STANDARD             I  \\virttsm\f$\FILES4

Where I need to key off of that damn (I). No changes, but grep just can't get er done...

Code:
0  B  06/11/2012 13:55:09             STANDARD             A  \\virttsm\f$\db001
0  B  06/11/2012 16:08:16             STANDARD             A  \\virttsm\f$\FILES
0  B  06/11/2012 13:03:39             STANDARD             I  \\virttsm\f$\FILES
0  B  06/11/2012 13:55:09             STANDARD             A  \\virttsm\f$\db001

---------- Post updated at 03:16 PM ---------- Previous update was at 03:14 PM ----------

Quote:
Originally Posted by Corona688
Code:
awk '$1 >= 0 { print $6 }'


this does not work...
# 5  
Old 06-26-2012
Of course it doesn't. You hadn't explained what you wanted in detail enough for me to make the right guess.

Working on it.
# 6  
Old 06-26-2012
So you just want to change the 6th column to "I" all the time?

You don't need 'grep' by the way.

Code:
awk '/0  B/ && ($1 >= 0) { $6="I"; print }'

# 7  
Old 06-26-2012
no i do not want to change anything, what I need is to find only the files that have the $6 column that is set to "I". I would like to grep/awk/sed out all the entries marked with an "A" in the same field....

---------- Post updated at 03:26 PM ---------- Previous update was at 03:20 PM ----------

Here it is, found on another forum, then modified...
dsmc q backup f:\* -subdir=yes -ina | grep "0 B" | awk "$1<=0" | awk "{ if ($6 ~ /I/) print $0}"
0 B 06/11/2012 13:03:39 STANDARD I \\virttsm\f$\FILES
0 B 06/11/2012 13:03:39 STANDARD I \\virttsm\f$\FILES1
0 B 06/11/2012 13:03:39 STANDARD I \\virttsm\f$\FILES2
0 B 06/11/2012 13:03:39 STANDARD I \\virttsm\f$\FILES3
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

One instance of comparing grep and awk

Hi. In thread https://www.unix.com/shell-programming-and-scripting/267833-grouping-counting.html rovf and I had a mini-discussion on grep and awk. Here is a demo script that compares the awk and grep approaches for this single problem: #!/usr/bin/env bash # @(#) s2 Demonstrate group... (1 Reply)
Discussion started by: drl
1 Replies

2. UNIX for Advanced & Expert Users

Grep the only instance name

Hi, I want to get the only application name from the server. Ex: if i give $ ps -ef | grep bw. It will show all BW process with entire path. It will little confuse to list out the process. Can anyone have syntax to get only the instance name. I need this for be, hawk,ems also. Please... (2 Replies)
Discussion started by: ckchelladurai
2 Replies

3. Shell Programming and Scripting

How can I just grep one instance of a word in the file

I want to grep some information out of the dmidecode but when I type dmidecode | grep Memory I get several instances of the word. Is there a way I can just choose which instance I want to display? (8 Replies)
Discussion started by: jcnewton13
8 Replies

4. Shell Programming and Scripting

grep for a string until instance of a space

Hey guys, I'm having a bit of trouble getting this to work using either sed or grep. It's possible awk might be the ticket I need as well, but my regulat expression skills aren't quite up to the task for doing this. I'm looking to grep for the string ERROR from the following log up until any... (6 Replies)
Discussion started by: terrell
6 Replies

5. Shell Programming and Scripting

grep second instance of same string

Hi all, i am new to unix scripting in ksh or any shell for that matter. I have downloaded a xml file from a website and saved on my local harddrive. inside the xml, the same tag is listed multiple times. <title>Tonight</title> <title>Thursday</title> <title>Friday</title>... (6 Replies)
Discussion started by: scubasteve39
6 Replies

6. Shell Programming and Scripting

How to use grep & find command to find references to a particular file

Hi all , I'm new to unix I have a checked project , there exists a file called xxx.config . now my task is to find all the files in the checked out project which references to this xxx.config file. how do i use grep or find command . (2 Replies)
Discussion started by: Gangam
2 Replies

7. Shell Programming and Scripting

awk - find first instance of string after NR==10

How do I use awk to find the NR of first instance of a specific string after eg NR==10? I need to find the first instance of the word "class" after a specific NR. (2 Replies)
Discussion started by: locoroco
2 Replies

8. UNIX for Dummies Questions & Answers

| help | unix | grep (GNU grep) 2.5.1 | advanced regex syntax

Hello, I'm working on unix with grep (GNU grep) 2.5.1. I'm going through some of the newer regex syntax using Regular Expression Reference - Advanced Syntax a guide. ls -aLl /bin | grep "\(x\)" Which works, just highlights 'x' where ever, when ever. I'm trying to to get (?:) to work but... (4 Replies)
Discussion started by: MykC
4 Replies

9. UNIX for Dummies Questions & Answers

grep, find or awk?

Since I found this very helpful forum and friendly people, I have a small request. I use AIX Unix and would like to know if there's a simple way how to do a kind of compare between two files. Should I use some grep, find or awk? I have 2 text files, let's name them file1 and file2. What I... (4 Replies)
Discussion started by: netrom
4 Replies

10. UNIX for Dummies Questions & Answers

Find command with Grep

I need to find for a particular string in my /opt file system. find . -exec grep "10000" {} \; I tried this command, it works ok but I want not to search in the logs folder I have in my filesystem as it takes lot of time. SO can I exclude one or more than on directory or sub directories from... (10 Replies)
Discussion started by: venu_nbk
10 Replies
Login or Register to Ask a Question