Sponsored Content
Top Forums Shell Programming and Scripting Extracting values based on line-column numbers from multiple text files Post 302960898 by RudiC on Saturday 21st of November 2015 08:55:32 AM
Old 11-21-2015
first approximation:
Code:
awk '
FNR == 1        {FC++
                 FN = FILENAME
                 if (FC < 3)    {OUT[FC] =  FN ".new"
                                 print > OUT[FC]
                                 next
                                }
                 printf "%s", LIN[FN,1] > OUT[1]
                 printf "%s", LIN[FN,2] > OUT[2]
                }
FC < 3          {LIN[$1,FC] = $0
                 BEG[$1,FC] = $2
                 STP[$1,FC] = $3
                 next
                }

FNR == BEG[FN,1]        {printf "\t%s\n", $STP[FN,1] > OUT[1]   
                        }
FNR == BEG[FN,2], \
FNR == STP[FN,2]        {printf "\t%s", $2 > OUT[2]
                        }
FNR == STP[FN,2]        {printf "\n"  > OUT[2]
                        }
'  task[12] file1
task1.new:
FileName    lineNumber    ColumnNumber    value    
file1    5    4    45
task2.new:
FileName    Line-start    line-end
file1    4    8    32    43    35    38    78

These 2 Users Gave Thanks to RudiC For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Joining multiple files based on one column with different and similar values (shell or perl)

Hi, I have nine files looking similar to file1 & file2 below. File1: 1 ABCA1 1 ABCC8 1 ABR:N 1 ACACB 1 ACAP2 1 ACOT1 1 ACSBG 1 ACTR1 1 ACTRT 1 ADAMT 1 AEN:N 1 AKAP1File2: 1 A4GAL 1 ACTBL 1 ACTL7 (4 Replies)
Discussion started by: seqbiologist
4 Replies

2. UNIX for Dummies Questions & Answers

Extracting rows from a text file based on the first column

I have a tab delimited text file where the first column can take on three different values : 100, 150, 250. I want to extract all the rows where the first column is 100 and put them into a separate text file and so on. This is what my text file looks like now: 100 rs3794811 0.01 0.3434... (1 Reply)
Discussion started by: evelibertine
1 Replies

3. UNIX for Dummies Questions & Answers

Extracting rows from a text file based on numerical values of a column

I have a text file where the second column is a list of numbers going from small to large. I want to extract the rows where the second column is smaller than or equal to 0.0001. My input: rs10082730 9e-08 12 46002702 rs2544081 1e-07 12 46015487 rs1425136 1e-06 7 35396742 rs2712590... (1 Reply)
Discussion started by: evelibertine
1 Replies

4. UNIX for Dummies Questions & Answers

Extracting rows from a space delimited text file based on the values of a column

I have a space delimited text file. I want to extract rows where the third column has 0 as a value and write those rows into a new space delimited text file. How do I go about doing that? Thanks! (2 Replies)
Discussion started by: evelibertine
2 Replies

5. Shell Programming and Scripting

Generate Codes based on start and End values of numbers in a column

Hello All, Could you please help with this. This is what I have: 506234.222 2 506234.222 2 506234.222 2 506234.222 2 508212.200 2 508212.200 2 333456.111 2 333456.111 2 333456.111 2 333456.111 2 But this is what I want: 506234.222 1 506234.222 2 506234.222 2 506234.222 3 (5 Replies)
Discussion started by: canimba
5 Replies

6. Shell Programming and Scripting

Split a file into multiple files based on line numbers and first column value

Hi All I have one query,say i have a requirement like the below code should be move to diffent files whose maximum lines can be of 10 lines.Say in the below example,it consist of 14 lines. This should be moved logically using the data in the fisrt coloumn to file1 and file 2.The data of first... (2 Replies)
Discussion started by: sarav.shan
2 Replies

7. UNIX for Dummies Questions & Answers

Extracting rows from a text file based on the values of two columns (given ranges)

Hi, I have a tab delimited text file with multiple columns. The second and third columns include numbers that have not been sorted. I want to extract rows where the second column includes a value between -0.01 and 0.01 (including both numbers) and the first third column includes a value between... (1 Reply)
Discussion started by: evelibertine
1 Replies

8. UNIX for Dummies Questions & Answers

Extracting lines from a text file based on another text file with line numbers

Hi, I am trying to extract lines from a text file given a text file containing line numbers to be extracted from the first file. How do I go about doing this? Thanks! (1 Reply)
Discussion started by: evelibertine
1 Replies

9. Shell Programming and Scripting

Extracting lines from text files in folder based on the numbers in another file

Hello, I have a file ff.txt that looks as follows *ABNA.txt 356 24 36 112 *AC24.txt 457 458 321 2 ABNA.txt and AC24.txt are the files in the folder named foo1. Based on the numbers in the ff.txt file, I want to extract the lines from the corresponding files in the foo1 folder and... (2 Replies)
Discussion started by: mohamad
2 Replies

10. Shell Programming and Scripting

Script for extracting data from csv file based on column values.

Hi all, I am new to shell script.I need your help to write a shell script. I need to write a shell script to extract data from a .csv file where columns are ',' separated. The file has 5 columns having values say column 1,column 2.....column 5 as below along with their valuesm.... (3 Replies)
Discussion started by: Vivekit82
3 Replies
SMP_CONF_GENERAL(8)						     SMP_UTILS						       SMP_CONF_GENERAL(8)

NAME
smp_conf_general - invoke CONFIGURE GENERAL SMP function SYNOPSIS
smp_conf_general [--connect=CO] [--expected=EX] [--help] [--hex] [--inactivity=IN] [--interface=PARAMS] [--nexus=NE] [--raw] [--sa=SAS_ADDR] [--verbose] [--version] SMP_DEVICE[,N] DESCRIPTION
Sends a SAS Management Protocol (SMP) CONFIGURE GENERAL request function to a SMP target. The SMP target is identified by the SMP_DEVICE and the --sa=SAS_ADDR. Depending on the interface, the SAS_ADDR may be deduced from the SMP_DEVICE. With one interface there is one SMP_DEVICE per machine so the SMP_DEVICE,N syntax is needed to differentiate between HBAs if there are multiple present. OPTIONS
Mandatory arguments to long options are mandatory for short options as well. -c, --connect=CO sets the "update STP maximum connect time limit" flag and the corresponding "STP maximum connect time limit" field to CO. Unit of CO is 100 microseconds. A CO of zero is taken to mean no maximum connection time limit. -E, --expected=EX set the 'expected expander change count' field in the SMP request. The value EX is from 0 to 65535 inclusive with 0 being the default value. When EX is greater than zero then if the value doesn't match the expander change count of the SMP target (i.e. the expander) when the request arrives then the target ignores the request and sets a function result of "invalid expander change count" in the response. -h, --help output the usage message then exit. -H, --hex output the response in hexadecimal. -i, --inactivity=IN sets the "update STP bus inactivity time limit" flag and the corresponding "STP bus inactivity time limit" field to IN. Unit of IN is 100 microseconds. A IN of zero is taken to mean no bus inactivity time limit. -I, --interface=PARAMS interface specific parameters. In this case "interface" refers to the path through the operating system to the SMP initiator. See the smp_utils man page for more information. -n, --nexus=NE sets the "update STP SMP I_T nexus loss time" flag and the corresponding "STP SMP I_T nexus loss time" field to NE. Unit of NE is one millisecond. A NE of zero is taken to mean a vendor specific amount of time; a NE of 65535 means the port shall never recognize an I_T nexus loss. -r, --raw send the response to stdout in binary. All error messages are sent to stderr. -s, --sa=SAS_ADDR specifies the SAS address of the SMP target device. Typically this is an expander. This option may not be needed if the SMP_DEVICE has the target's SAS address within it. The SAS_ADDR is in decimal but most SAS addresses are shown in hexadecimal. To give a number in hexadecimal either prefix it with '0x' or put a trailing 'h' on it. -v, --verbose increase the verbosity of the output. Can be used multiple times -V, --version print the version string and then exit. CONFORMING TO
The SMP CONFIGURE GENERAL function was introduced in SAS-2 . AUTHORS
Written by Douglas Gilbert. REPORTING BUGS
Report bugs to <dgilbert at interlog dot com>. COPYRIGHT
Copyright (C) 2006-2008 Douglas Gilbert This software is distributed under a FreeBSD license. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PUR- POSE. SEE ALSO
smp_utils, smp_rep_general(smp_utils) smp_utils-0.93 January 2008 SMP_CONF_GENERAL(8)
All times are GMT -4. The time now is 12:37 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy