Sponsored Content
Full Discussion: AWK Challenge
Top Forums Shell Programming and Scripting AWK Challenge Post 302168063 by matrixmadhan on Saturday 16th of February 2008 10:09:35 PM
Old 02-16-2008
Quote:
If I do a awk '/SQL-2005-UserDB/ { print }' filename won't that print each SQL-2005-UserDB that is found. I the file its looking at there may be multiple SQL-2005-userDB. Out of all it finds I need to print only the one that matches the current date and one that is the latest time.
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

 

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
ISCSICTL(8)						    BSD System Manager's Manual 					       ISCSICTL(8)

NAME
iscsictl -- program to manage iSCSI instances SYNOPSIS
iscsictl [-d sockdir] command [arguments ...] DESCRIPTION
The iscsictl utility manages iSCSI instances on the local computer. It talks to the iscsid(8) program to perform this management. iSCSI is a method for transferring SCSI commands across a TCP connection. The client which issues the SCSI command is called the initiator, and the device which receives the command and takes action is called the target; this mirrors SCSI devices, although instead of being physi- cally attached to a host, the SCSI commands and responses take place over a network. iSCSI communication is done in sessions. The iSCSI initiator logs in to a target across the network, possibly authenticating itself; this creates an iSCSI session between initiator and target. The initiator can then issue commands to and read responses from the target. Firstly, the iSCSI initiator on the local machine must be made aware of the network location of the target. The add_send_target is used in iscsictl to do this. The targets can be listed using the list_targets command. To login from the initiator to the target, the login command is used; this creates a session between the initiator and target. The sessions can be listed by using the list_sessions command. Global Options -d sockdir Specify the directory where the socket for iscsid(8) lives. Target Address Specification The target address specification for the add_target and add_send_target commands may include a target name, target address (IP or FQDN), TCP port, and group tag. Either the target address or target name is required. (For add_send_target, a target address is required). The address, port, and group tag may optionally be repeated. -a target-address Specify the target address by IP or FQDN. -n target-name Specify the target by name. -p port-num The TCP port to connect to the target on. (Default port is 3260) -g group-tag The group tag, a 16-bit integer. Portal Address Specification The portal address specification for the add_portal command may include an address (IP or FQDN), port, and group tag, plus portal options. -a target-address Specify the target address by IP or FQDN. -p port-num The TCP port to connect to the target on. (Default port is 3260) -g group-tag The group tag, a 16-bit integer. -h Use a CRC32 header digest. -d Use a CRC32 data digest. -l segment-length Specify the max received data segment length. Target Options Target options are as follows: -h Use a CRC32 header digest. -d Use a CRC32 data digest. -w time Time to wait. -r time Time to retain. -e level Error recovery level. -l segment-length Specify the max received data segment length. Authentication Options Authentication options are as follows: -t type Specify authentication type. n indicates no authentication, while c indicates CHAP authentication, and C indicates Mutual CHAP authentication. -u name User name. -s secret Initiator secret. -S secret Target secret. Commands The iscsictl command argument is taken from one of the following options: version return version information from the iscsictl utility and the iscsid(8) daemon. add_target target-address-spec [target-opts] [auth-opts] [-N symbolic-name] A target-address-spec may include name, address, port, and group tag, with address/port/tag possibly repeated. add_portal portal-address-spec [-I -target-id] [-N -symbolic-name] Add a portal to the list of portals. remove_target -I target-id remove_target -n target-name Remove a target by name or ID. slp_find_targets Not implemented. refresh_targets [-I target-id] this command causes the iSCSI initiator to refresh its view of the iSCSI targets to which it is connected. If this command completes successfully, an ``OK'' value is printed. For more context on the exact usage of this command, please see the example below. list_targets Display a list of targets the iSCSI initiator knows about. add_send_target -a target-address [target-address-spec] [target-opts] [auth-opts] [-N symbolic-name] this command allows the iSCSI initiator to connect to an iSCSI target. The subsequent -a target provides the address of the target. This can be provided as a numerical IP address, or as a textual FQDN. For more context on the exact usage of this command, please see the example below. remove_send_target -I target-id remove_send_target -n target-name Remove a send target from the list by name or target-id list_send_targets Display the list of send targets configured. add_isns_server iSNS-address-spec Add an iSNS server using an address specification that may include name, address, and port. remove_isns_server -I isns-server-id remove_isns_server -a isns-server-address find_isns_servers Not Implemented. list_isns_servers refresh_isns [-I id] login [-m] [target-opts] [auth-opts] [-P portal-id] To be able to communicate with the iSCSI target, the initiator must login. This command allows this login to take place. The subse- quent -P session argument provides the session which should be used to perform the login. On successful completion of this command, the session which has been created will be displayed, along with the connection number. For more context on the exact usage of this command, please see the example below. logout [-I session-id] add_connection [-m] [target-opts] [auth-opts] [-P portal-id] remove_connection -I session-id -C connection-id inquiry [-l lun] [-d detail] [-p pag] read_capacity [-I session-id [-l lun]] report_luns [-I session-id] test_unit_ready [-I session-id] add_initiator -a interface-address [-N symbolic-name] remove_initiator -I portal-id list_initiators list_sessions [-c] Once login to the target has taken place, a session will have been created. To list the session information, this command is used. The session number and target information for each of the targets are displayed. If the -c flag is used, connection information is displayed as well. For more context on the exact usage of this command, please see the example below. set_node_name -n initiator-name [-A -alias] [-i isid] Set the initiator name. The default initiator name is iqn.1994-04.org.netbsd:iscsi.<hostname>:<hostid> . An alias can be specified as well as an isid EXAMPLES
iscsictl is intended to be used as follows: The initiator itself can be loaded as a kernel module, and works successfully on 2.0 (the host called "burner"), running against the NetBSD target on a 5.99 host. burner# modload -v -s -p /usr/lkm/iscsi_post.sh /usr/lkm/iscsidrv.o modload: reserving 36864 bytes of memory Module loaded as ID 0 burner# iscsid iSCSI Daemon loaded burner# iscsictl add_send_target -a 172.16.135.133 Added Send Target 1 burner# iscsictl refresh_targets OK burner# iscsictl list_targets 1: iqn.1994-04.org.netbsd.iscsi-target:target0 2: 172.16.135.133:3260,1 burner# iscsictl login -P 2 Created Session 2, Connection 1 burner# iscsictl list_sessions Session 2: Target iqn.1994-04.org.netbsd.iscsi-target:target0 burner# newfs /dev/rsd0a /dev/rsd0a: 100.0MB (204800 sectors) block size 8192, fragment size 1024 using 4 cylinder groups of 25.00MB, 3200 blks, 6144 inodes. super-block backups (for fsck -b #) at: 32, 51232, 102432, 153632, burner# mount /dev/sd0a /mnt burner# df Filesystem 1K-blocks Used Avail Capacity Mounted on /dev/wd0a 4066094 186994 3675795 4% / kernfs 1 1 0 100% /kern /dev/sd0a 99247 1 94283 0% /mnt burner# dmesg | egrep '(scsibus|sd0)' scsibus0 at bha2: 16 targets, 8 luns per target scsibus0: waiting 2 seconds for devices to settle... scsibus1 at iscsi0: 1 target, 16 luns per target sd0 at scsibus1 target 0 lun 0: <NetBSD, NetBSD iSCSI, 0> disk fixed sd0: fabricating a geometry sd0: 100 MB, 100 cyl, 64 head, 32 sec, 512 bytes/sect x 204800 sectors sd0: fabricating a geometry sd0: fabricating a geometry sd0: fabricating a geometry burner# and, on the target end of the iSCSI session: Reading configuration from `/etc/iscsi/targets' target0:rw:0.0.0.0/0 extent0:/tmp/iscsi-target0:0:104857600 DISK: 1 logical unit (204800 blocks, 512 bytes/block), type iscsi fs DISK: LUN 0: 100 MB disk storage for "target0" TARGET: iSCSI Qualified Name (IQN) is iqn.1994-04.org.netbsd.iscsi-target > iSCSI Discovery login successful from iqn.1994-04.org.netbsd:iscsi.burner.cupertino.alistaircrooks.com:0 on 172.16.135.137 disk -1, ISID 70368764559360, TSIH 1 < iSCSI Discovery logout successful from iqn.1994-04.org.netbsd:iscsi.burner.cupertino.alistaircrooks.com:0 on 172.16.135.137 disk -1, ISID 70368764559360, TSIH 1 > iSCSI Normal login successful from iqn.1994-04.org.netbsd:iscsi.burner.cupertino.alistaircrooks.com:0 on 172.16.135.137 disk 0, ISID 70368764559360, TSIH 2 SEE ALSO
iscsid(8) HISTORY
The iscsictl utility appeared in NetBSD 6.0. AUTHORS
Alistair Crooks <agc@NetBSD.org> wrote this manual page. The iscsictl utility was contributed by Wasabi Systems, Inc. BSD
May 26, 2012 BSD
All times are GMT -4. The time now is 01:19 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy