Sponsored Content
Top Forums Shell Programming and Scripting Extract numbers from output file and compare to value Post 303011545 by MadeInGermany on Friday 19th of January 2018 11:47:57 AM
Old 01-19-2018
I like the shell solution in post#2, it is also a bit closer to the attempt in post#1.
Looping over the values is somewhat simpler than over the indexes
Code:
read -a intf < test.txt
for i in "${intf[@]}"
do
  IFS=',:=' read ifname status _ tx _ rx <<< "$i"
  # strip from the end up to a non-digit: % or bps or .0 or .0%
  echo "This is interface ${ifname} with status ${status} and rx ${rx%%[!0-9]*} and tx ${tx%%[!0-9]*}"
done

This User Gave Thanks to MadeInGermany For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

I need to extract last column of a file and compare the values

Hi, I am new to unix and I need help in solving below mentioned issue, really appreciate ur help. I have a file sam, john, 2324, 07142007 tom, thomson, 2343, 07142007 john, scott, 2478, 07142007 its a comma delimited file, I need to extract the last column from each line and this... (4 Replies)
Discussion started by: vukkusila
4 Replies

2. Shell Programming and Scripting

read numbers from file and output which numbers belongs to which range

Howdy experts, We have some ranges of number which belongs to particual group as below. GroupNo StartRange EndRange Group0125 935300 935399 Group2006 935400 935476 937430 937459 Group0324 935477 935549 ... (6 Replies)
Discussion started by: thepurple
6 Replies

3. Shell Programming and Scripting

Extract numbers from text file work out average

Just wondering if someone could assist me with shell script I'm trying to write. I need to read the final column of a text file (shown below) and workout what the average number is. The text file will have a variable number of lines, I just want the script to pull out the values in the final field... (14 Replies)
Discussion started by: rich@ardz
14 Replies

4. UNIX for Dummies Questions & Answers

Extract numbers from .txt file

I need to extract all the p-value numbers and the rho numbers from a .txt file and write them as coma separated values in a new file. Ideally I would get two files in the end, one for p- values and one for rho. Any suggestions? I appreciate your help!!! The .txt file looks essentially like this... (5 Replies)
Discussion started by: eggali
5 Replies

5. Shell Programming and Scripting

Need help please with Grep/Sed command to extract text and numbers from a file

Hello All, I need to extract lines from a file that contains ALPHANUMERIC and the length of Alphanumeric is set to 16. I have pasted the sample of the lines from the text file that I have created. My problem is that sometimes 16 appears in other part of the line. I'm only interested to... (14 Replies)
Discussion started by: mnassiri
14 Replies

6. Shell Programming and Scripting

Extract rows from file based on row numbers stored in another file

Hi All, I have a file which is like this: rows.dat 1 2 3 4 5 6 3 4 5 6 7 8 7 8 9 0 4 3 2 3 4 5 6 7 1 2 3 4 5 6 I have another file with numbers like these (numbers.txt): 1 3 4 5 I want to read numbers.txt file line by line. The extract the row from rows.dat based on the... (3 Replies)
Discussion started by: shoaibjameel123
3 Replies

7. Shell Programming and Scripting

compare 2 files and extract the data which is not present in other file with condition

I have 2 files whose data's are as follows : fileA 00 lieferungen 00 attractiop 01 done 02 forness 03 rasp 04 alwaysisng 04 funny 05 done1 fileB alwayssng dkhf fdgdfg dfgdg sdjkgkdfjg funny rasp (7 Replies)
Discussion started by: rajniman
7 Replies

8. UNIX for Dummies Questions & Answers

Compare two column in file and extract complate line

No Chr Pos Qual GT_1 GT_2 1. chr1 478493 595 A/G G/G 2. chr1 879243 700 A/T T/T 3. chr2 889922 1300 C/C C/C 4. chr2 1926372 300 T/A T/A 5. chr3 237474 500 G/C C/C 6. chr3 575757 700 ... (2 Replies)
Discussion started by: mscott
2 Replies

9. UNIX for Dummies Questions & Answers

Extract Numbers from a log file

Hi, I am trying to grep/extract the number list from this log file, can I get some help on this. I can grep the word 'href' to see the numbers, but it is resulting with the complete line. Content of my file: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <html> <head>... (4 Replies)
Discussion started by: Sajjadmehdi
4 Replies

10. Shell Programming and Scripting

Extract numbers from file name-how to ?

Hello friends,I am new to Unix programming. how do I achieve the following in Unix shell script (I am running ksh on AIX) extract the number from name of file? My file format is like "LongFileName-1234.020614-221030.txt" now I want to extract value which is between (-) hyphen and (.) dot... (4 Replies)
Discussion started by: f150
4 Replies
STRUCT 
USB_DRIVER(9) Host-Side Data Types and Macro STRUCT USB_DRIVER(9) NAME
struct_usb_driver - identifies USB interface driver to usbcore SYNOPSIS
struct usb_driver { const char * name; int (* probe) (struct usb_interface *intf,const struct usb_device_id *id); void (* disconnect) (struct usb_interface *intf); int (* unlocked_ioctl) (struct usb_interface *intf, unsigned int code,void *buf); int (* suspend) (struct usb_interface *intf, pm_message_t message); int (* resume) (struct usb_interface *intf); int (* reset_resume) (struct usb_interface *intf); int (* pre_reset) (struct usb_interface *intf); int (* post_reset) (struct usb_interface *intf); const struct usb_device_id * id_table; struct usb_dynids dynids; struct usbdrv_wrap drvwrap; unsigned int no_dynamic_id:1; unsigned int supports_autosuspend:1; unsigned int disable_hub_initiated_lpm:1; unsigned int soft_unbind:1; }; MEMBERS
name The driver name should be unique among USB drivers, and should normally be the same as the module name. probe Called to see if the driver is willing to manage a particular interface on a device. If it is, probe returns zero and uses usb_set_intfdata to associate driver-specific data with the interface. It may also use usb_set_interface to specify the appropriate altsetting. If unwilling to manage the interface, return -ENODEV, if genuine IO errors occurred, an appropriate negative errno value. disconnect Called when the interface is no longer accessible, usually because its device has been (or is being) disconnected or the driver module is being unloaded. unlocked_ioctl Used for drivers that want to talk to userspace through the "usbfs" filesystem. This lets devices provide ways to expose information to user space regardless of where they do (or don't) show up otherwise in the filesystem. suspend Called when the device is going to be suspended by the system either from system sleep or runtime suspend context. The return value will be ignored in system sleep context, so do NOT try to continue using the device if suspend fails in this case. Instead, let the resume or reset-resume routine recover from the failure. resume Called when the device is being resumed by the system. reset_resume Called when the suspended device has been reset instead of being resumed. pre_reset Called by usb_reset_device when the device is about to be reset. This routine must not return until the driver has no active URBs for the device, and no more URBs may be submitted until the post_reset method is called. post_reset Called by usb_reset_device after the device has been reset id_table USB drivers use ID table to support hotplugging. Export this with MODULE_DEVICE_TABLE(usb,...). This must be set or your driver's probe function will never get called. dynids used internally to hold the list of dynamically added device ids for this driver. drvwrap Driver-model core structure wrapper. no_dynamic_id if set to 1, the USB core will not allow dynamic ids to be added to this driver by preventing the sysfs file from being created. supports_autosuspend if set to 0, the USB core will not allow autosuspend for interfaces bound to this driver. disable_hub_initiated_lpm if set to 0, the USB core will not allow hubs to initiate lower power link state transitions when an idle timeout occurs. Device-initiated USB 3.0 link PM will still be allowed. soft_unbind if set to 1, the USB core will not kill URBs and disable endpoints before calling the driver's disconnect method. DESCRIPTION
USB interface drivers must provide a name, probe and disconnect methods, and an id_table. Other driver fields are optional. The id_table is used in hotplugging. It holds a set of descriptors, and specialized data may be associated with each entry. That table is used by both user and kernel mode hotplugging support. The probe and disconnect methods are called in a context where they can sleep, but they should avoid abusing the privilege. Most work to connect to a device should be done when the device is opened, and undone at the last close. The disconnect code needs to address concurrency issues with respect to open and close methods, as well as forcing all pending I/O requests to complete (by unlinking them as necessary, and blocking until the unlinks complete). COPYRIGHT
Kernel Hackers Manual 3.10 June 2014 STRUCT USB_DRIVER(9)
All times are GMT -4. The time now is 08:30 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy