Sponsored Content
Top Forums Shell Programming and Scripting Remove entire line from a file if 1st column matches a pattern Post 302946646 by RavinderSingh13 on Thursday 11th of June 2015 03:22:07 AM
Old 06-11-2015
Hello Anshu Rajan,

Kindly use code tags for commands/inputs/codes used in your posts in spite of HTML codes. Could you please try following and let me know if that helps.
Code:
awk -F"|" -vvar=5 '{if($1 !~ /[[:alpha:]]/ && $1 !~ /[[:punct:]]/ && length($1) <= var){print}}'  Input_file

Output will be as follows.
Code:
03942|ronald F|ronaldf
36152|anshu ran|aran2

Thanks,
R. Singh
This User Gave Thanks to RavinderSingh13 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace Entire line if any part matches regexp

Hey guys, I have a file that I've slowly been awking, seding, and greping for data entry. I am down to pull the addresses out to insert them into an excel file. Each address is a few lines, but i want to put a semicolon delimiter in between each address so I can export the text file into excel and... (6 Replies)
Discussion started by: Cocoabean
6 Replies

2. Shell Programming and Scripting

replace a column in a file if it matches certain pattern

Hi, I want to replace a column in a file if it matches certain pattern. Can you help me on this. Here is the file content. 000000 1111111 2222222 011111 0123445 1234556 023445 1111111 2343455 if second column contains 1111111 i need to replace it with 0000000 Can you... (6 Replies)
Discussion started by: Krrishv
6 Replies

3. 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

4. Shell Programming and Scripting

Remove if the above line matches pattern

but keep if does not I have a file: --> my.out foo: bar foo: moo blarg i am on vacation foo: goose foo: lucy foo: moose foo: stucky groover@monkey.org foo: bozo grimace@gonzo.net dear sir - blargo blargo foo: goon foo: sloppy foo: saudi gimme gimme gimme (3 Replies)
Discussion started by: spacegoose
3 Replies

5. Shell Programming and Scripting

Replace column that matches specific pattern, with column data from another file

Can anyone please help with this? I have 2 files as given below. If 2nd column of file1 has pattern foo1@a, find the matching 1st column in file2 & replace 2nd column of file1 with file2's value. file1 abc_1 foo1@a .... abc_1 soo2@a ... def_2 soo2@a .... def_2 foo1@a ........ (7 Replies)
Discussion started by: prashali
7 Replies

6. Shell Programming and Scripting

Print entire line only if certain fixed character matches the string

Hi All, I have a file testarun.txt contains the below lines and i want to print the lines if the character positions 7-8 matches 01. 201401011111 201401022222 201402013333 201402024444 201403015555 201403026666 201404017777 201404028888 201405019999 201405020000 I am trying the... (4 Replies)
Discussion started by: Arunprasad
4 Replies

7. Shell Programming and Scripting

How to get a 1st line which matches the particular pattern?

Hi all, I have file on which I do grep on "/tmp/data" then I get 5 lines as dir Path: /tmp/data/20162343134 Starting to listen on ports logging: -- Moving results files from local storage: /tmp/resultsFiles/20162343134/*.gz to NFS: /data/temp/20162343134/outgoing from above got to get... (7 Replies)
Discussion started by: girijajoshi
7 Replies

8. Shell Programming and Scripting

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

I have a file with class c IP addresses that I need to match to a column and print the matching lines of another file. I started playing with grep -if file01.out file02.out but I am stuck as to how to match it to a column and print the matching lines; cat file01.out 10.150.140... (5 Replies)
Discussion started by: lewk
5 Replies

9. UNIX for Beginners Questions & Answers

Compare 1st column from 2 file and if match print line from 1st file and append column 7 from 2nd

hi I have 2 file with more than 10 columns for both 1st file apple,0,0,0...... orange,1,2,3..... mango,2,4,5..... 2nd file apple,2,3,4,5,6,7... orange,2,3,4,5,6,8... watermerlon,2,3,4,5,6,abc... mango,5,6,7,4,6,def.... (1 Reply)
Discussion started by: tententen
1 Replies

10. UNIX for Beginners Questions & Answers

If pattern in column 3 matches pattern in column 2 (any row), print value in column 1

Hi all, I have searched and searched, but I have not found a solution that quite fits what I am trying to do. I have a long list of data in three columns. Below is a sample: 1,10,8 2,12,10 3,13,12 4,14,14 5,15,16 6,16,18 Please use code tags What I need to do is as follows: If a... (4 Replies)
Discussion started by: bleedingturnip
4 Replies
QSqlField(3qt)															    QSqlField(3qt)

NAME
QSqlField - Manipulates the fields in SQL database tables and views SYNOPSIS
#include <qsqlfield.h> Public Members QSqlField ( const QString & fieldName = QString::null, QVariant::Type type = QVariant::Invalid ) QSqlField ( const QSqlField & other ) QSqlField & operator= ( const QSqlField & other ) bool operator== ( const QSqlField & other ) const virtual ~QSqlField () virtual void setValue ( const QVariant & value ) virtual QVariant value () const virtual void setName ( const QString & name ) QString name () const virtual void setNull () bool isNull () const virtual void setReadOnly ( bool readOnly ) bool isReadOnly () const void clear ( bool nullify = TRUE ) QVariant::Type type () const DESCRIPTION
The QSqlField class manipulates the fields in SQL database tables and views. QSqlField represents the characteristics of a single column in a database table or view, such as the data type and column name. A field also contains the value of the database column, which can be viewed or changed. Field data values are stored as QVariants. Using an incompatible type is not permitted. For example: QSqlField f( "myfield", QVariant::Int ); f.setValue( QPixmap() ); // will not work However, the field will attempt to cast certain data types to the field data type where possible: QSqlField f( "myfield", QVariant::Int ); f.setValue( QString("123") ); // casts QString to int QSqlField objects are rarely created explicitly in application code. They are usually accessed indirectly through QSqlRecord or QSqlCursor which already contain a list of fields. For example: QSqlCursor cur( "Employee" ); // create cursor using the 'Employee' table QSqlField* f = cur.field( "name" ); // use the 'name' field f->setValue( "Dave" ); // set field value ... In practice we rarely need to extract a pointer to a field at all. The previous example would normally be written: QSqlCursor cur( "Employee" ); cur.setValue( "name", "Dave" ); ... See also Database Classes. MEMBER FUNCTION DOCUMENTATION
QSqlField::QSqlField ( const QString & fieldName = QString::null, QVariant::Type type = QVariant::Invalid ) Constructs an empty field called fieldName of type type. QSqlField::QSqlField ( const QSqlField & other ) Constructs a copy of other. QSqlField::~QSqlField () [virtual] Destroys the object and frees any allocated resources. void QSqlField::clear ( bool nullify = TRUE ) Clears the value of the field. If the field is read-only, nothing happens. If nullify is TRUE (the default), the field is set to NULL. bool QSqlField::isNull () const Returns TRUE if the field is currently NULL; otherwise returns FALSE. bool QSqlField::isReadOnly () const Returns TRUE if the field's value is read only; otherwise returns FALSE. QString QSqlField::name () const Returns the name of the field. Example: sql/overview/table4/main.cpp. QSqlField &; QSqlField::operator= ( const QSqlField & other ) Sets the field equal to other. bool QSqlField::operator== ( const QSqlField & other ) const Returns TRUE if the field is equal to other; otherwise returns FALSE. Fields are considered equal when the following field properties are the same: name() isNull() value() isReadOnly() void QSqlField::setName ( const QString & name ) [virtual] Sets the name of the field to name. void QSqlField::setNull () [virtual] Sets the field to NULL and clears the value using clear(). If the field is read-only, nothing happens. See also isReadOnly() and clear(). void QSqlField::setReadOnly ( bool readOnly ) [virtual] Sets the read only flag of the field's value to readOnly. See also setValue(). void QSqlField::setValue ( const QVariant & value ) [virtual] Sets the value of the field to value. If the field is read-only (isReadOnly() returns TRUE), nothing happens. If the data type of value differs from the field's current data type, an attempt is made to cast it to the proper type. This preserves the data type of the field in the case of assignment, e.g. a QString to an integer data type. For example: QSqlCursor cur( "Employee" ); // 'Employee' table QSqlField* f = cur.field( "student_count" ); // an integer field ... f->setValue( myLineEdit->text() ); // cast the line edit text to an integer See also isReadOnly(). QVariant::Type QSqlField::type () const Returns the field's type. QVariant QSqlField::value () const [virtual] Returns the value of the field as a QVariant. Example: sql/overview/table4/main.cpp. SEE ALSO
http://doc.trolltech.com/qsqlfield.html http://www.trolltech.com/faq/tech.html COPYRIGHT
Copyright 1992-2001 Trolltech AS, http://www.trolltech.com. See the license file included in the distribution for a complete license statement. AUTHOR
Generated automatically from the source code. BUGS
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you. The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech. If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qsqlfield.3qt) and the Qt version (3.1.1). Trolltech AS 9 December 2002 QSqlField(3qt)
All times are GMT -4. The time now is 10:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy