Sponsored Content
Full Discussion: AWK Challenge
Top Forums Shell Programming and Scripting AWK Challenge Post 302168067 by netmedic on Saturday 16th of February 2008 11:22:18 PM
Old 02-17-2008
Quote:
Originally Posted by matrixmadhan
Yes it would do.

Assuming the logs are generated in a timely fashion so the last message in the file would have the latest timestamp

Code:
awk '/pattern/{a=$0}END{ print a }' filename

That looks like it would work. Can you put a variable in the pattern?
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

A find and sort challenge...

Hi, I need to generate a listing of files that have been changed since x day. the listing is to be sorted by date. I managed to get the 1st requirement using the find command : find . -mtime -100 -type f -ls but I don't know how to sort the ls listing by date. :( The challenge comes... (4 Replies)
Discussion started by: ppohz
4 Replies

2. UNIX for Dummies Questions & Answers

Loaded question - anyone up to the challenge?

Hello everyone. I am new to these forums and also new to Unix. And by saying "new to Unix" I mean I have never used it and 10 minutes ago was asked to start learning. So here I am. I was wondering if anyone could help me find out how long it would take to write code in Unix that will do the... (1 Reply)
Discussion started by: idesaj
1 Replies

3. UNIX for Advanced & Expert Users

safeword challenge

Hi, there are some servers here at work which issue a Safeword challenge after I login. Can anyone tell me exactly how the challenge/response system works? In particular, how are the valid keys decided? (2 Replies)
Discussion started by: blowtorch
2 Replies

4. UNIX for Dummies Questions & Answers

A challenge for you sed/awk wizards...

Here's a challenge for you wizards... I have a file formatted as follows; $ What I need to output is; 87654321 Bobby One 12345678 Bobby One 09876543 Bobby One 1107338 Bobby! Two Any Ideas how I can do this? I've tried sed but I'm not sure if perl might be a better way to... (2 Replies)
Discussion started by: th3g0bl1n
2 Replies

5. Shell Programming and Scripting

regex challenge

Here's a regex substitution operation that has stumped me with sed: How do you convert lines like this: first.key ?{x.y.z} second.key ?{xa.ys.zz.s} third.key ?{xa.k} to: first.key ?{x_y_z} second.key ?{xa_ys_zz_s} third.key ?{xa_k} So i'm basically converting all the... (11 Replies)
Discussion started by: neked
11 Replies

6. Shell Programming and Scripting

Geo Weather Challenge

Hi everybody, I'm new to these forums and this is my first post. A couple days ago I was trying to find a simple script that would return an individual's local weather conditions using I.P. based geolocation. After many failed search attempts, I began my quest to create this for myself. I have to... (0 Replies)
Discussion started by: o0110o
0 Replies

7. Shell Programming and Scripting

PS1 challenge

Ok then i Have a challenge for you : Give me PS1 so that it always display the least 2 levels of directory (except if i am above of course) I want it this way : so if i go to / /home/ /home/user /home/user/whatever /home/user/whatever1/whatever2 my PS1 should respectively... (12 Replies)
Discussion started by: ctsgnb
12 Replies

8. UNIX for Dummies Questions & Answers

Touch Challenge

I've been given a directory full of subdirectories full of logfiles of the same name: /logfiles/day1/file1/blockednodes.csv day1-14 file1-48 The above is the actual directory structure for 14 days worth of a logfile that is generated every 30 minutes. It's been done this way to preserve the... (15 Replies)
Discussion started by: Cludgie
15 Replies

9. UNIX for Advanced & Expert Users

Interesting awk/Perl/sed parsing challenge

I have a log with entries like: out/target/product/imx53_smd/obj/STATIC_LIBRARIES/libwebcore_intermediates/Source/WebCore/bindings/V8HTMLVideoElement.cpp : target thumb C++: libwebcore <=... (8 Replies)
Discussion started by: glev2005
8 Replies

10. Shell Programming and Scripting

Anyone like a challenge?

I have searched through google, and this forum to try and find the answer, but alas, nothing quite hits the whole answer. I am trying to read the last line (or lines) of some log files. I do this often. The files are named sequentially, using the date as part of the file name, and appending... (18 Replies)
Discussion started by: BatterBits
18 Replies
stmfadm(1M)						  System Administration Commands					       stmfadm(1M)

NAME
stmfadm - SCSI target mode framework command line interface SYNOPSIS
stmfadm add-hg-member -g, --group-name group-name group-member... stmfadm add-tg-member -g, --group-name group-name group-member... stmfadm add-view [-n, --lun logical-unit-number -t, --target-group group-name -h, --host-group group-name] lu-name stmfadm create-hg group-name stmfadm create-tg group-name stmfadm delete-hg group-name stmfadm delete-tg group-name stmfadm list-hg [-v] [host-group-name...] stmfadm list-tg [-v] [target-group-name...] stmfadm list-lu [-v] [lu-name...] stmfadm list-target [-v] [target-name...] stmfadm list-view -l, --lu-name lu-name [entry-name...] stmfadm list-state stmfadm remove-hg-member -g, --group-name group-name group-member... stmfadm remove-tg-member -g, --group-name group-name group-member... stmfadm remove-view -l, --lu-name lu-name entry-name DESCRIPTION
The stmfadm command configures logical units within the SCSI Target Mode Framework (STMF) framework. The framework and this man page use the following terminology: initiator A device responsible for issuing SCSI I/O commands to a SCSI target and logical unit. target A device responsible for receiving SCSI I/O commands for a logical unit. logical unit A device within a target responsible for executing SCSI I/O commands. logical unit number The identifier of a logical unit within a target. initiator group An initiator group is a set of one or more initiators that are combined for the purposes of being applied to a view (see below). An initiator cannot be a member of more than one initiator group. target group A target group is a set of one or more SCSI target ports that are combined for the purposes of being applied to a view (see below). A target port cannot be a member of more than one target group. view A view defines the association of an initiator group, a target group, and a logical unit number with a specified logical unit. Any view entry added to a logical unit must not be in conflict with existing view entries for that logical unit. A view entry is considered to be in conflict when an attempt is made to duplicate the association of any given initiator, target and logical unit number. As an exam- ple, logical unit LU_0 has the following view entry associated with it: Logical Unit: LU_0 View Entry: 0 initiator group: HostA target group: All targets logical unit number: 32 If you attempted the following: # stmf add-view -n 31 -h HostA LU_0 ...the operation would return an error with a message indicating that the view entry is in conflict with one or more existing view entries. This conflict arises because the existing view entry, 0, already has mapped LU_0 to logical unit number 32 for the initiator group HostA. SUB-COMMANDS The stmfadm command supports the subcommands listed below. add-view [-n, --lun logical-unit-number -t, --target-group group-name -h, --host-group group-name] lu-name Adds a logical unit view entry to a logical unit lu-name, where lu-name is the STMF name for the logical unit as displayed by the list- lu subcommand. The add-view subcommand provides the user with a mechanism to implement access control for a logical unit and also pro- vides a means of assigning a logical unit number to a logical unit for a given set of initiators and targets. A logical unit will not be available to any initiators until at least one view is applied. Each view entry gets assigned an entry name, which can be used to reference the entry in the remove-view and list-view subcommands. add-view supports the following options: -n, --lun logical-unit-number logical-unit-number is an integer in the range 0-16383 to be assigned to the logical unit for this view entry. If this option is not specified, a logical unit number will be assigned by the STMF framework. -t, --target-group group-name group-name is the name of a target group previously created using the STMF create-tg subcommand. If this option is not specified, the logical unit will be available through all targets. -h, -host-group group-name group-name is the name of an host group previously created using the STMF create-hg subcommand. If this option is not specified, the logical unit will be available to all initiators that log in to the STMF framework. add-hg-member -g group-name group member... Add a host group member to a host group. group-name must be an existing group created using the create-hg subcommand. group member can be specified as name_type.name_value, where name_type can be one of the following: wwn iqn eui ...and name_value is the value of the initiator name. As an example, to add a fibre channel initiator port world-wide name 200000e08b909221 to the host group HostA, the command would be: # stmfadm add-hg-member -g HostA wwn.200000e08b909221 To add an ISCSI initiator node member with the name iqn.1986-03.com.sun:01.46f7e262 to HostA, the command would be: # stmfadm add-hg-member -g HostA iqn.1986-03.com.sun:01.46f7e262 Alternatively, members can be specified using their SCSI name string identifiers. To add the two initiators above using their SCSI name string identifiers, the commands would be: # stmfadm add-hg-member -g HostA eui.200000e08b909221 # stmfadm add-hg-member -g HostA iqn.1986-03.com.sun:01.46f7e262 A host group member cannot be a member of more than one host group. add-tg-member -g group-name group member... Add a target group member to a target group. group-name must be an existing group created using the create-tg subcommand. group member can be specified as name_type.name_value, where name_type can be one of the following: wwn iqn eui ...and name_value is the value of the target name. As an example, to add a fibre channel target port world-wide name 501000e092376af7 to the target group TG0, the command would be: # stmfadm add-tg-member -g TG0 wwn.501000e092376af7 To add an ISCSI target member with the name iqn.1986-03.com.sun:target.01.01110 to TG0, the command would be: # stmfadm add-tg-member -g TG0 iqn.1986-03.com.sun:target.01.01110 Alternatively, members can be specified using their SCSI name string identifiers. To add the two targets above using their SCSI name string identifiers, the commands would be: # stmfadm add-tg-member -g TG0 eui.501000e092376af7 # stmfadm add-tg-member -g TG0 iqn.1986-03.com.sun:target.01.01110 A target group member cannot be a member of more than one target group. create-hg group-name Create an initiator group with the name group-name. group-name is a string of Unicode characters with a maximum length of 255. The group name must be unique within the STMF system. create-tg group-name Create a target group with the name group-name. group-name is a string of Unicode characters with a maximum length of 255. The group name must be unique within the STMF system. delete-hg group-name Delete the host group that identified by group-name. delete-tg group-name Delete the target group that identified by group-name. list-hg [-v,--verbose] [host-group-name...] Lists information for the host group in the system referenced by host-group-name. If host-group-name is not specified, all host groups in the system will be listed. If the --v or --verbose option is specified, all members within a host group are displayed. list-target [-v,--verbose] [target-name...] Lists information for the target port in the system referenced by target-name. If target name is not specified, all target ports in the system will be listed. If the -v or --verbose option is specified, additional information about the target along with SCSI session information for logged-in initiators is displayed. list-tg [-v,--verbose] [target-group-name...] Lists information for the target group in the system referenced by target-group-name. If target-group-name is not specified, all tar- get groups in the system will be listed. If the --v or --verbose option is specified, all members within a target group are displayed. list-lu [-v,--verbose] [lu-name...] Lists information for the logical unit in the system referenced by lu-name. If lu-name is not specified, all logical units in the sys- tem will be listed. If the -v or --verbose option is specified, additional information about the logical unit will be displayed. list-view --l, --lu-name lu-name [entry-name...] Lists the view entry for the logical unit referenced by lu-name. If entry-name is not specified, all view entries for the specified logical unit will be listed. list-state Lists the operational and configuration state of the STMF. remove-hg-member -g group-name group member Removes a host group member from a host group. group-name must be an existing group created using the create-hg subcommand. group mem- ber can be specified as name_type.name_value, where name_type can be one of the following: wwn iqn eui ...and name_value is the value of the initiator name. As an example, to remove the fibre channel initiator port world-wide name 200000e08b909221 from the host group HostA, the command would be: # stmfadm remove-hg-member -g HostA wwn.200000e08b909221 To remove the ISCSI initiator node member with the name iqn.1986-03.com.sun:01.46f7e262 from HostA, the command would be: # stmfadm remove-hg-member -g HostA iqn.1986-03.com.sun:01.46f7e262 Alternatively, members can be specified using their SCSI name string identifiers. To remove the two initiators above using their SCSI name string identifiers, the commands would be: # stmfadm remove-hg-member -g HostA eui.200000e08b909221 # stmfadm remove-hg-member -g HostA iqn.1986-03.com.sun:01.46f7e262 remove-tg-member -g group-name group member Removes a target group member from a target group. group-name must be an existing group created using the create-tg subcommand. group member can be specified as name_type.name_value, where name_type can be one of the following: wwn iqn eui ...and name_value is the value of the target name. As an example, to remove the fibre channel target port world-wide name 501000e092376af7 from the target group TG0, the command would be: # stmfadm remove-tg-member -g TG0 wwn.501000e092376af7 To remove the ISCSI target member with the name iqn.1986-03.com.sun:target.01.01110 from TG0, the command would be: # stmfadm remove-tg-member -g TG0 iqn.1986-03.com.sun:target.01.01110 Alternatively, members can be specified using their SCSI name string identifiers. To remove the two targets above using their SCSI name string identifiers, the commands would be: # stmfadm remove-tg-member -g TG0 eui.501000e092376af7 # stmfadm remove-tg-member -g TG0 iqn.1986-03.com.sun:target.01.01110 remove-view --l, --lu-name lu-name entry-name Removes one or more logical unit view entries from a logical unit. EXAMPLES
Example 1 Creating a Host group with Two Initiator Ports The following commands use the create-hg and add-hg-member subcommands to create a host group and add two initiator ports to that host group. # stmfadm create-hg host-group-a # stmfadm add-hg-member -g host-group-a wwn.210105b0000d92d0 Example 2 Adding a View Entry to a Logical Unit The following command uses the add-view subcommand to allow access from host-group-a to a logical unit. # stmfadm add-view -h host-group-a 6000AE40C5000000000046FC4FEA001C Example 3 Listing a View Entry The following command uses the list-view subcommand to list all view entries for the specified logical unit. # stmfadm list-view -l 6000AE40C5000000000046FC4FEA001C View Entry: 0 Host group : host-group-a Target group : All LUN : 0 ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWstmfu | +-----------------------------+-----------------------------+ |Interface Stability |Committed | +-----------------------------+-----------------------------+ SEE ALSO
sbdadm(1M), attributes(5) SunOS 5.11 8 Jan 2009 stmfadm(1M)
All times are GMT -4. The time now is 08:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy