Sponsored Content
Top Forums Shell Programming and Scripting awk strings search + print next column after match Post 302567406 by zaxxon on Monday 24th of October 2011 06:53:40 AM
Old 10-24-2011
Ok, but I deleted my answer as I just noticed that you are looking for the next column, not next row. My example would only have helped if you were looking for rows.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Awk+Grep Input file needs to match a column and print the entire line

I'm having problems since few days ago, and i'm not able to make it works with a simple awk+grep script (or other way to do this). For example, i have a input file1.txt: cat inputfile1.txt 218299910417 1172051195 1172070231 1172073514 1183135117 1183135118 1183135119 1281440202 ... (3 Replies)
Discussion started by: poliver
3 Replies

2. Shell Programming and Scripting

awk search column, print line

Hello. I've been banging my head against walls trying to search a comma delimited file, using awk. I'm trying to search a "column" for a specific parameter, if it matches, then I'd like to print the whole line. I've read in multiple texts: awk -F, '{ if ($4 == "string") print $0 }'... (2 Replies)
Discussion started by: Matthias03
2 Replies

3. Shell Programming and Scripting

exact string match ; search and print match

I am trying to match a pattern exactly in a shell script. I have tried two methods awk '/\<mpath${CURR_MP}\>/{print $1 $2}' multipath perl -ne '/\bmpath${CURR_MP}\b/ and print' /var/tmp/multipath Both these methods require that I use the escape character. I am guessing that is why... (8 Replies)
Discussion started by: bash_in_my_head
8 Replies

4. Shell Programming and Scripting

Strings from one file which exactly match to the 1st column of other file and then print lines.

Hi, I have two files. 1st file has 1 column (huge file containing ~19200000 lines) and 2nd file has 2 columns (small file containing ~6000 lines). ################################# huge_file.txt a a ab b ################################## small_file.txt a 1.5 b 2.5 ab ... (4 Replies)
Discussion started by: AshwaniSharma09
4 Replies

5. Shell Programming and Scripting

Print strings that match pattern with awk

I have a file with many lines which contain strings like .. etc. But with no rule regarding field separators or anything else. I want to print ONLY THE STRING from each line , not the entire line !!! For example from the lines : Flow on service executed with success in . Performances... (5 Replies)
Discussion started by: black_fender
5 Replies

6. Shell Programming and Scripting

Print only lines where fields concatenated match strings

Hello everyone, Maybe somebody could help me with an awk script. I have this input (field separator is comma ","): 547894982,M|N|J,U|Q|P,98,101,0,1,1 234900027,M|N|J,U|Q|P,98,101,0,1,1 234900023,M|N|J,U|Q|P,98,54,3,1,1 234900028,M|H|J,S|Q|P,98,101,0,1,1 234900030,M|N|J,U|F|P,98,101,0,1,1... (2 Replies)
Discussion started by: Ophiuchus
2 Replies

7. Shell Programming and Scripting

awk Print New Column For Every Two Lines and Match On Multiple Column Values to print another column

Hi, My input files is like this axis1 0 1 10 axis2 0 1 5 axis1 1 2 -4 axis2 2 3 -3 axis1 3 4 5 axis2 3 4 -1 axis1 4 5 -6 axis2 4 5 1 Now, these are my following tasks 1. Print a first column for every two rows that has the same value followed by a string. 2. Match on the... (3 Replies)
Discussion started by: jacobs.smith
3 Replies

8. UNIX for Beginners Questions & Answers

Match Strings between two files, print portions of each file together when matched ([g]awk)

I have two files and desire to use the strings from $1 of file 1 (file1.txt) as search criteria to find matches in $2 of file 2 (file2.txt). If matches are found I want to output the entire line of file 2 (file2.txt) followed by fields $2-$11 of file 1 (file1.txt). I can find the matches, I cannot... (7 Replies)
Discussion started by: jvoot
7 Replies

9. Shell Programming and Scripting

awk to print match or non-match and select fields/patterns for non-matches

In the awk below I am trying to output those lines that Match between file1 and file2, those Missing in file1, and those missing in file2. Using each $1,$2,$4,$5 value as a key to match on, that is if those 4 fields are found in both files the match, but if those 4 fields are not found then missing... (0 Replies)
Discussion started by: cmccabe
0 Replies

10. UNIX for Beginners Questions & Answers

Use strings from nth field from one file to match strings in entire line in another file, awk

I cannot seem to get what should be a simple awk one-liner to work correctly and cannot figure out why. I would like to use patterns from a specific field in one file as regex to search for matching strings in the entire line ($0) of another file. I would like to output the lines of File2 which... (1 Reply)
Discussion started by: jvoot
1 Replies
Alzabo::Runtime::Row(3pm)				User Contributed Perl Documentation				 Alzabo::Runtime::Row(3pm)

NAME
Alzabo::Runtime::Row - Row objects SYNOPSIS
use Alzabo::Runtime::Row; my $row = $table->row_by_pk( pk => 1 ); $row->select('foo'); $row->update( bar => 5 ); $row->delete; DESCRIPTION
These objects represent actual rows from the database containing actual data. In general, you will want to use the "Alzabo::Runtime::Ta- ble" object to retrieve rows. The "Alzabo::Runtime::Table" object can return either single rows or row cursors. ROW STATES
Row objects can have a variety of states. Most row objects are "live", which means they represent an actual row object. A row can be changed to the "deleted" state by calling its "delete()" method. This is a row that no longer exists in the database. Most method calls on rows in this state cause an exception. There is also a "potential" state, for objects which do not represent actual database rows. You can call "make_live()" on these rows in order to change their state to "live". Finally, there is an "in cache" state, which is identical to the "live" state, except that it is used for object's that are cached via the "Alzabo::Runtime::UniqueRowCache" class. METHODS
Row objects offer the following methods: select (@list_of_column_names) Returns a list of values matching the specified columns in a list context. In scalar context it returns only a single value (the first column specified). If no columns are specified, it will return the values for all of the columns in the table, in the order that are returned by "Alzabo::Run- time::Table->columns". This method throws an "Alzabo::Runtime::NoSuchRowException" if called on a deleted row. select_hash (@list_of_column_names) Returns a hash of column names to values matching the specified columns. If no columns are specified, it will return the values for all of the columns in the table. This method throws an "Alzabo::Runtime::NoSuchRowException" if called on a deleted row. update (%hash_of_columns_and_values) Given a hash of columns and values, attempts to update the database to and the object to represent these new values. It returns a boolean value indicating whether or not any data was actually modified. This method throws an "Alzabo::Runtime::NoSuchRowException" if called on a deleted row. refresh Refreshes the object against the database. This can be used when you want to ensure that a row object is up to date in regards to the database state. This method throws an "Alzabo::Runtime::NoSuchRowException" if called on a deleted row. delete Deletes the row from the RDBMS and changes the object's state to deleted. For potential rows, this method simply changes the object's state. This method throws an "Alzabo::Runtime::NoSuchRowException" if called on a deleted row. id_as_string Returns the row's id value as a string. This can be passed to the "Alzabo::Runtime::Table->row_by_id" method to recreate the row later. For potential rows, this method always return an empty string. This method throws an "Alzabo::Runtime::NoSuchRowException" if called on a deleted row. is_live Indicates whether or not the given row represents an actual row in the database. is_potential Indicates whether or not the given row represents an actual row in the datatbase. is_deleted Indicates whether or not the given row has been deleted table Returns the "Alzabo::Runtime::Table" object that this row belongs to. schema Returns the "Alzabo::Runtime::Schema" object that this row's table belongs to. This is a shortcut for "$row->table->schema". rows_by_foreign_key This method is used to retrieve row objects from other tables by "following" a relationship between two tables. It takes the following parameters: * foreign_key => "Alzabo::Runtime::ForeignKey" object Given a foreign key object, this method returns either a row object or a row cursor object the row(s) in the table to which the relation- ship exist. The type of object returned is based on the cardinality of the relationship. If the relationship says that there could only be one match- ing row, then a row object is returned, otherwise it returns a cursor. POTENTIAL ROWS
The "potential" row state is used for rows which do not yet exist in the database. These are created via the "Alzabo::Runtime::Ta- ble->potential_row" method. They are useful when you need a placeholder object which you can update and select from, but you don't actually want to commit the data to the database. These objects are not cached. Once "make_live()" is called, the object's state becomes "live". Potential rows have looser constraints for column values than regular rows. When creating a new potential row, it is ok if none of the columns are defined. If a column has a default, and a value for that column is not given, then the default will be used. However, you cannot update a column in a potential row to undef (NULL) if the column is not nullable. No attempt is made to enforce referential integrity constraints on these objects. You cannot set a column's value to a database function like "NOW()", because this requires interaction with the database. make_live This method inserts the row into the database and changes the object's state to "live". This means that all references to the potential row object will now be references to the real object (which is a good thing). This method can take any parameters that can be passed to the "Alzabo::Runtime::Table->insert" method. Any columns already set will be passed to the "insert" method, including primary key values. However, these will be overridden, on a col- umn by column basis, by a "pk" or "values" parameters given to the "(make_live()" method. Calling this method on a row object that is not in the "potential" state will cause an "Alzabo::Runtime::LogicException" AUTHOR
Dave Rolsky, <autarch@urth.org> perl v5.8.8 2007-12-23 Alzabo::Runtime::Row(3pm)
All times are GMT -4. The time now is 09:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy