Sponsored Content
Top Forums Shell Programming and Scripting Moving String in a File on the top Post 302637421 by agama on Tuesday 8th of May 2012 10:58:15 PM
Old 05-08-2012
This would be one way:

Code:
awk '
    /Col1;Col2;Col3/ {
        have = 1;
        print;
        for( j = 0; j < i; j++ )
            print buf[j];
        next;
    }
    !have { buf[i++] = $0; next; }
    { print; }
' input-file >output-file

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

moving a file?

i'm trying to move a file from one diectory to another and rename it at the same time. but its giving me an error . " mv: cannot unlink /dir2/file5 : No such file or directory" here is the command I'm using. mv /dir1/file1 /dir2/file5 solaris 8 (1 Reply)
Discussion started by: Holistic
1 Replies

2. Shell Programming and Scripting

Finding & Moving Oldest File by Parsing/Sorting Date Info in File Names

I'm trying to write a script that will look in an /exports folder for the oldest export file and move it to a /staging folder. "Oldest" in this case is actually determined by date information embedded in the file names themselves. Also, the script should only move a file from /exports to... (6 Replies)
Discussion started by: nikosey
6 Replies

3. AIX

Top command in AIX 4.2 (no topas, no nmon, no top)?

Is there a 'top' command equivalent in AIX 4.2 ? I already checked and I do not see the following ones anywhere: top nmon topas (1 Reply)
Discussion started by: Browser_ice
1 Replies

4. AIX

Need a list of top 10 CPU using processes (also top 10 memory hogs, separately)

Okay, I am trying to come up with a multi-platform script to report top ten CPU and memory hog processes, which will be run by our enterprise monitoring application as an auto-action item when the CPU and Memory utilization gets reported as higher than a certain threshold I use top on other... (5 Replies)
Discussion started by: thenomad
5 Replies

5. Shell Programming and Scripting

Need help in finding filesize , moving file , gzipping file

Hi , Please help with the following questions 1) how can i find size of a file ? i have written du -k $flname > s1 . Is this right ? Any other better suggeastions ? 2) how do I use mv command for moving the file ? I need the syntax with some examples 3) Command for printing the total... (1 Reply)
Discussion started by: Learning!
1 Replies

6. Shell Programming and Scripting

replace (sed?) a single line/string in file with multiple lines (string) from another file??

Can someone tell me how I can do this? e.g: Say file1.txt contains: today is monday the 22 of NOVEMBER 2010 and file2.txt contains: the 11th month of How do i replace the word NOVEMBER with (5 Replies)
Discussion started by: tuathan
5 Replies

7. UNIX for Advanced & Expert Users

Insert string in binary file at top

How can i append a EBCDIC string of 100 bytes to 0th position of a binary file in UNIX. (4 Replies)
Discussion started by: param_it
4 Replies

8. Shell Programming and Scripting

Search for string and print top and bottom line

Hi Folks I need a one liner to parse through a log and if the string is found print the line above, the line with the string and the line below. example: The ball is green and blue Billy through the ball higer. Jane got hurt with the ball. So if I search for Billy I would need the 3... (1 Reply)
Discussion started by: bombcan
1 Replies

9. Shell Programming and Scripting

Moving files based on size (string to integer)

I have a log file that I want to archive out as it reaches 100MB. I am using the following to get the file size into a variable but get the error "line 5: filesize=$(wc -c < logfile.log) if then echo "is greater than 100M" else echo "is less than 100M" fi I'm sure there's something... (2 Replies)
Discussion started by: Flakman
2 Replies

10. UNIX for Advanced & Expert Users

Need help on moving .csv file from UNIX to windows file path

Need help on moving .csv file from unix to windows file path. (1 Reply)
Discussion started by: lakshmanraok117
1 Replies
usb_get_string_descr(9F)				   Kernel Functions for Drivers 				  usb_get_string_descr(9F)

NAME
usb_get_string_descr - Get string descriptor from device SYNOPSIS
#include <sys/usb/usba.h> int usb_get_string_descr(dev_info_t *dip, uint16_t langid, uint8_t index, char *buf, size_t buflen); INTERFACE LEVEL
Solaris DDI specific (Solaris DDI) PARAMETERS
dip Pointer to the device's dev_info structure. langid Language ID. Currently only USB_LANG_ID (English ascii) is valid. index String index indicating descriptor to retrieve. buf Address into which the string descriptor is placed. buflen Size of buf in bytes. DESCRIPTION
The usb_get_string_descr() function retrieves a parsed string descriptor from a device. dip specifies the device, while index indicates which descriptor to return. String descriptors provide information about other descriptors, or information that is encoded in other descriptors, in readable form. Many descriptor types have one or more index fields which identify string descriptors. (See Sections 9.5 and 9.6 of the USB 2.0 specifica- tion.) For example, a configuration descriptor's seventh byte contains the string descriptor index describing a specific configuration. Retrieved descriptors that do not fit into buflen bytes are truncated. All returned descriptors are null-terminated. RETURN VALUES
USB_SUCCESS String descriptor is returned in buf. USB_INVALID_ARGS dip or buf are NULL, or index or buflen is 0. USB_FAILURE Descriptor cannot be retrieved. CONTEXT
May be called from user or kernel context. EXAMPLES
/* Get the first string descriptor. */ char buf[SIZE]; if (usb_get_string_descr( dip, USB_LANG_ID, 0, buf, SIZE) == USB_SUCCESS) { cmn_err (CE_NOTE, "%s%d: %s", ddi_driver_name(dip), ddi_get_instance(dip), buf); } ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Architecture |PCI-based systems | +-----------------------------+-----------------------------+ |Interface stability |Committed | +-----------------------------+-----------------------------+ |Availability |SUNWusb | +-----------------------------+-----------------------------+ SEE ALSO
attributes(5), usb_get_dev_data(9F), usb_string_descr(9S) SunOS 5.11 5 Jan 2004 usb_get_string_descr(9F)
All times are GMT -4. The time now is 04:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy