Sponsored Content
Top Forums Shell Programming and Scripting line break if string exceeds 100chars Post 302490914 by s1ckle on Wednesday 26th of January 2011 06:14:46 AM
Old 01-26-2011
line break if string exceeds 100chars

I am required to develop a script to look for specific strings in the /var/adm/messages file on our Solaris10 host. When an entry is found in the file then I need that line to be piped to a log file. I have a script with the criteria i just need help with the manipulation of the text string.

1. I need to replace the time stamps in /var/adm/messages and replace it with the format shown below. I need a way to replace collumn 1, 2 and 3 with the date example below.

date example:
Code:
# date '+%D %T'
01/26/11 12:40:56

2. I also need to make the string continue on a new line if it exceeds 100 chars, so that the log file looks pretty and not wrapped around on a standard sized monitor.

original line:
Code:
Jan  26 12:40:56 hostname usba: [ID 912658 kern.info] USB 2.0 device (usb430,a2) operating at full speed (USB 1.x) on USB 2.0 external hub: keyboard@4, hid3 at bus address 5

format I would like in my log file:
Code:
01/26/11 12:40:56 hostname usba: [ID 912658 kern.info] USB 2.0 device (usb430,a2) operating at full
01/26/11 12:40:56 speed (USB 1.x) on USB 2.0 external hub: keyboard@4, hid3 at bus address 5

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to insert line break + string in vi (search & replace )

Hello all i have big test file that has allot of structure text something like this : <foo1 *.html> <blah action> somthing 1 somthing 2 </blah> </foo1 > now i will like to insert 2 more lines of text below the <blah action> so it will be like : <foo1... (1 Reply)
Discussion started by: umen
1 Replies

2. Shell Programming and Scripting

Break down a string

I am wondering how can I take a variable that may have multiple items of data and to use each one indenpendently. For example lets say that.... data=/lcl/apps/trm, /lcl/apps/wwe, /prd/sse/qwe, /lcl/ppe/eer Now I would like to be able to process each item found within the data string. As... (5 Replies)
Discussion started by: LRoberts
5 Replies

3. Shell Programming and Scripting

BASH: Break line, read, break again, read again...

...when the lines use both a colon and commas to separate the parts you want read as information. The first version of this script used cut and other non-Bash-builtins, frequently, which made it nice and zippy with little more than average processor load in GNOME Terminal but, predictably, slow... (2 Replies)
Discussion started by: SilversleevesX
2 Replies

4. Shell Programming and Scripting

Add line break for each line in a file

I cannot seem to get this to work.. I have a file which has about 100 lines, and there is no end of line (line break \n) at the end of each line, and this is causing problem when i paste them into an application. the file looks like this this is a test that is a test balblblablblhblbha... (1 Reply)
Discussion started by: fedora
1 Replies

5. Shell Programming and Scripting

break the string and print it in a new line after a specific word

Hi Gurus I am new to this forum.. I am using HP Unix OS. I have one single string in input file as shown below Abc123 | cde | fgh | ghik| lmno | Abc456 |one |two |three | four | Abc789 | five | Six | seven | eight | Abc098 | ........ I want to achive the result in a output file as shown... (3 Replies)
Discussion started by: kannansr621
3 Replies

6. Shell Programming and Scripting

Trying to take a string and break each letter into a separate variable

I am trying to make a script that takes a word and each letter up and turns it into a separate variable. My code currently does not work but I feel I just need to tweak one thing that I am unsure of. (ex: if forum was typed in letter1=f; letter2=o; letter3=r;...) Thank you count=1; ... (7 Replies)
Discussion started by: crimputt
7 Replies

7. UNIX for Dummies Questions & Answers

Insert a break page after certain string using SED

Hi: I have 2 files: teststring.txt and a tempfile.txt teststring file contains: s/Primary Ins./\n1/g I'm trying to search for "Primary Ins." string in tempfile. For every "Primary Ins." string that is found, a new line is inserted and put in number 1. Then, write out the newfile... (7 Replies)
Discussion started by: newbeee
7 Replies

8. UNIX for Dummies Questions & Answers

add a string to a file without line break

I searched and found "echo -n" and "printf" are solution for this, but they are not here: $ echo "hello" >> test $ cat test hello $ echo -n "world" >> test $ cat test hello world $ echo -n " seriously?" >> test $ cat test hello world seriously? This is not successful... (15 Replies)
Discussion started by: stunn3r
15 Replies

9. Shell Programming and Scripting

How to break the line to the one above?

Hello everyone! I'm trying to make the below file1 look like file2, can anyone help? Basically I just hit backspace on every line that starts with a number. Thanks! file1: THIS#IS-IT1 4 THIS#IS-IT2 3 THIS#IS-IT3 2 THIS#IS-IT4 1 Result > file2: (4 Replies)
Discussion started by: demmel
4 Replies

10. UNIX for Dummies Questions & Answers

Find a string across line break (because of "segmentation fault core dumped")

Hi, thanks to a precedent post, and thanks to the reply of derekludwig of the forum, I have convert my first awk command as : test.txt is : AAAAAGHIJKLAjKMEFJKLjklABCDJkLEFGHIJKL awk -f findstring.awk test.txt > textreturn.txtfindstring.awk is : BEGIN{ SLENGTH = 3 } { ... (3 Replies)
Discussion started by: thewizarde6
3 Replies
hubd(7D)																  hubd(7D)

NAME
hubd - USB hub driver SYNOPSIS
hub@unit-address The hubd is a USBA (Solaris USB Architecture) compliant client driver that supports USB hubs conforming to the Universal Serial Bus Speci- fication 2.0. The hubd driver supports bus-powered and self-powered hubs. The driver supports hubs with individual port power, ganged power and no power switching. When a device is attached to a hub port, the hubd driver enumerates the device by determining its type and assigning an address to it. For multi-configuration devices, hubd sets the preferred configuration (refer to cfgadm_usb(1M) to select a configuration). The hubd driver attaches a driver to the device if one is available for the default or selected configuration. When the device is disconnected from the hub port, the hubd driver offlines any driver instance attached to the device. /kernel/drv/hubd 32- bit ELF kernel module /kernel/drv/amd64/hubd 64- bit ELF kernel module /kernel/drv/sparcv9/hubd 64-bit SPARC ELF kernel module See attributes(5) for a description of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Architecture |SPARC, , PCI-based systems | +-----------------------------+-----------------------------+ |Availability |SUNWusb | +-----------------------------+-----------------------------+ cfgadm_usb(1M), attributes(5), usba(7D) Writing Device Drivers Universal Serial Bus Specification 2.0 System Administration Guide: Basic Administration http://www.sun.com/io In addition to being logged, the following messages may also appear on the system console. Messages are formatted in the following manner: WARNING: <device path> <hubd<instance number>): Message... where <instance number> is the instance number of hubd and <device path> is the physical path to the device in /devices directory. Messages from the root hub are displayed with a usb<instance number> prefix instead of hub<instance number> as the root hub is an integrated part of the host controller. Connecting device on port <number> failed. The driver failed to enumerate the device connected on port <number> of hub. If enumeration fails, disconnect and re-connect. Use of a USB 1.0 hub behind a high speed port may cause unexpected failures. Devices connected to a USB 1.0 hub which are in turn connected to an external USB 2.0 hub, may misbehave unexpectedly or suddenly go offline. This is due to a documented incompatibility between USB 1.0 hubs and USB 2.0 hub Transaction Translators. Please use only USB 2.0 or USB 1.1 hubs behind high-speed ports. Connecting a high speed device to a non-high speed hub (port x) will result in a loss of performance. Please connect the device to a high speed port to get the maximum performance. USB 2.0 devices connected to USB 1.0 or 1.1 hubs cannot run at their highest speed, even when the hub is in turn connected to a high- speed port. For best performance, reconnect without going through a USB 1.0 or 1.1 hub. Cannot access <device>. Please reconnect. This hub has been disconnected because a device other than the original one has been inserted. The driver informs you of this fact by displaying the name of the original device. Devices not identical to the previous one on this port. Please disconnect and reconnect. Same condition as described above; however in this case, the driver is unable to identify the original device with a name string. Hub driver supports max of <n> ports on hub. Hence, using the first <number of physical ports> of <n> ports available. The current hub driver supports hubs that have <n> ports or less. A hub with more than <n> ports has been plugged in. Only the first <n> out of the total <number of physical ports> ports are usable. The following messages may be logged into the system log. They are formatted in the following manner: <device path> <hubd<instance number>): message... Global over current condition, please disconnect hub. The driver detected an over current condition. This means that the aggregate current being drawn by the devices on the downstream port exceeds a preset value. Refer to section 7.2.1.2 and 11.13 of the Universal Serial Bus Specification 2.0. You must remove and insert this hub to render it and its downstream devices functional again. If this message continues to display for a particular hub, you may need to remove downstream devices to eliminate the problem. Local power has been lost, please disconnect hub. A USB self-powered hub has lost external power. All USB devices connected down-stream from this hub will cease to function. Disconnect the hub, plug in the external power-supply and then plug in the hub again. Local power has been lost, the hub could draw <x> mA power from the USB bus. A USB self/bus-powered hub has lost external power. Some USB devices connected down-stream from this hub may cease to func- tion. Disconnect the external power-supply and then plug in the hub again. 20 June 2005 hubd(7D)
All times are GMT -4. The time now is 11:20 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy