4

Bash - Delete rows that do not end with a number

 2 years ago
source link: https://www.codesd.com/item/bash-delete-rows-that-do-not-end-with-a-number.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Bash - Delete rows that do not end with a number

advertisements

I need to remove all lines (in text file) not ending with a number.

Before:

 Frog
 Toad 8
 Snake 3
 Spider

After:

 Toad 8
 Snake 3


Try this with GNU sed to edit "in place":

sed -i '/[^0-9]$/d' file

Related Articles

How to delete all files that do not end with certain formats?

So to remove all files ending with .lnx, the cmd would be rm *.lnx, right? If I want to remove all files that do NOT end with [.lnx], what command should I use? Is there such a thing? ls | grep -v '\.lnx$' | xargs rm

Show values ​​that do not end with & ldquo; .0 & rdquo; Python Pandas

I have a float column that contains NaN values and float values. How do i filter out those values that does not end with .0? For example: Col1 0.7 1.0 1.1 9.0 9.5 NaN Desire result will be: Col1 0.7 1.1 9.2 You can use boolean indexing: #convert to s

How to copy files into a shell that does not end with a certain file extension

For example copy all files that do not end with .txtBash will accept a not pattern. cp !(*.txt)

Look for lines that do not end with a given character

I'm searching in a file for lines that do not end with a backslash (\), but they must begin with some text, so I've written: if ( $cur_line =~ m{\A\s+(.+?)(?!\\)\z/xms ){ ... # parentheses are only for testing } But with the above $1 always contains

Select Query | Select entries that do not start with a number - MySQL

I need to select all entries that do not start with a number between 1-9. Example Entries: 6300 Dog Lane Kitty Drive 500 Bird Chrest 800 Tire Road Johnson Ave Park Ave So if I ran a query on the above I would expect: Kitty Drive Johnson Ave Park Ave

How to find files that do not end with & ldquo; .log & rdquo; in the bash / shell script

I am new to bash/shell scripting. I want to find all the files in directory and subdirectories, which do not end with ".log". I know I can use the below command to get the files which ends with ".log", but I need the ones which do not

vba deleting rows that do not contain defined defined values ​​in the range

I have a sheet of data with 25k lines. I need to search the entire sheet for certain words that I've defined in a named range on tab 2, called "KeywordSearh". The range contains a list of words I need to look up in the main data. I want to delet

Regex to identify rows that do not contain the exact number of occurrences of branded characters with Notepad ++

I would like to be able to jump to rows that dont contain 6 quotemarks in a quoted-CSV file as it feels like a good way to identify broken rows. I think using a regular expression with Notepad++'s find features would be a sensible approach but I'm no

Xslt produces a result that does not end with a carriage return (newline)

I have an xslt script that transforms an xml file to another xml file. The problem I'm having is that the resulting xml file does not end with a newline like a well behaved linux file. I'm using <xsl:output method="xml" indent="yes"

Find files that do not end with specific extensions

I'm making a bash script; how do I find files not ending with specific extensions? #!/bin/bash find . -type f -print | grep "\.\(?!psd\|xcf\).+$" Thank you.You can use: find . -regextype posix-egrep -type f ! -regex '.*\.(psd|xcf)$' Or without r

Backbone.js route using regex - Corresponding to a URL that does not end with a given string

I have to create a route using regex that matches a URL which does not end with a particular word say 'submit'. For example - /login/submit ==> does not match /login/abcsubmit ==> does not match /abc/xyx => MatchesUse this regex: ((?!(.*?)/\w*sub

UNIX found to find file names that do not end with specific extensions?

Is there a simple way to recursively find all files in a directory hierarchy, that do not end in a list of extensions? E.g. all files that are not *.dll or *.exe UNIX/GNU find, powerful as it is, doesn't seem to have an exclude mode (or I'm missing i

List all files that do not start with a number

I want to examine the all the key files present in my /proc. But /proc has innumerable directories corresponding to the running processes. I don't want these directories to be listed. All these directories' names contain only numbers. As I am poor in

Join lines that do not end with a comma

I have a CSV file produced by MS Excel. Where merged cells exist in the original spreadsheet, the original rows containing these become multi-line in the CSV output. I would like to join these back into one line. I am looking for a Unix (Solaris 10)

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK