Sponsored Content
Top Forums Shell Programming and Scripting awk removing data before or after a pattern Post 302443370 by BeefStu on Sunday 8th of August 2010 01:33:58 PM
Old 08-08-2010
awk removing data before or after a pattern

I have the following data:

01:00:00 29 10 20 41
01:20:00 18 6 34 42
01:40:00 28 5 24 43
02:00:01 11 7 8 74
02:20:01 19 15 12 54
02:40:01 1 4 0 95
03:00:01 1 3 0 96
03:20:01 0 0 0 99
03:40:01 1 2 0 97

First I want to remove all data after a certain pattern, Ie 03:00 sp this
should leave me with the following results

01:00:00 29 10 20 41
01:20:00 18 6 34 42
01:40:00 28 5 24 43
02:00:01 11 7 8 74
02:20:01 19 15 12 54
02:40:01 1 4 0 95
03:00:01 1 3 0 96


Secondly I would also like to know how to remove all before the pattern
so this should leave me with the following results.

03:00:01 1 3 0 96
03:20:01 0 0 0 99
03:40:01 1 2 0 97

Note: Both these statements not be run at the same time.

Thanks to all who answer.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

removing a line containing a pattern in sed

i need to use sed to remove an entire line containing a pattern stored in a variable say $var1 this var1 will be a URL and will therefore contain slashes any help would be greatly appreciated (1 Reply)
Discussion started by: Fire_Storm
1 Replies

2. Shell Programming and Scripting

Replacing or removing a long list of pattern by using awk or sed

Input: >abc|123456|def|EXIT| >abc|203456|def|EXIT2| >abc|234056|def|EXIT3| >abc|340056|def|EXIT4| >abc|456000|def|EXIT5| . . . Output: def|EXIT| def|EXIT2| def|EXIT3| def|EXIT4| def|EXIT5| . . My try code: (9 Replies)
Discussion started by: patrick87
9 Replies

3. Shell Programming and Scripting

SFTP to server, pulling data and removing the data

Hi all, I have the following script, but are not too sure about the syntax to complete the script. In essence, the script must connect to a SFTP server at a client site with username and password located in a file on my server. Then change to the appropriate directory. Pull the data to the... (1 Reply)
Discussion started by: codenjanod
1 Replies

4. Shell Programming and Scripting

Removing data with pattern matching

I have the following: HH:MM:SS I want to use either % or # sign to remove :SS can somebody please provide me an example. I know how to do this in awk, but awk is too much overhead for something this simple since I will be doing this in a loop a lot of times. Thanks in advance to all... (2 Replies)
Discussion started by: BeefStu
2 Replies

5. Shell Programming and Scripting

Removing repeating lines from a data frame (AWK)

Hey Guys! I have written a code which combines lots of files into one big file(.csv). However, each of the original files had headers on the first line, and now that I've combined the files the headers are interspersed throughout the new combined data frame. For example, throughout the data... (21 Replies)
Discussion started by: gd9629
21 Replies

6. Shell Programming and Scripting

how to get data from hex file using SED or AWK based on pattern sign

I have a binary (hex) file I need to parse to get some data which are encoded this way: .* b4 . . . 01 12 .* af .* 83 L1 x1 x2 xL 84 L2 y1 y2 yL By another words there is a stream of hexadecimal bytes (in my example separated by space for better readability). I need to get value stored in... (3 Replies)
Discussion started by: sameucho
3 Replies

7. Shell Programming and Scripting

Removing files matching a pattern

I am on ubuntu 11.10 using bash scripts I want to remove all files matching a string pattern and I am using the following code find . -name "*$pattern*" -exec rm -f {} \;I have encountered a problem when $pattern is empty. In this case all my files in my current directory were deleted. This... (3 Replies)
Discussion started by: kristinu
3 Replies

8. Shell Programming and Scripting

Removing a pattern in a line

Dear team, I have a file curve.csv which is generated from oracle and each line has a comment associated with it, I want to get rid of this comment, can you please suggest me a command as how to do it Eg, cat curve.csv /*data for today curve*/ /*data for text1*/ this is the header /*data... (6 Replies)
Discussion started by: infyanurag
6 Replies

9. UNIX for Dummies Questions & Answers

Removing PATTERN from txt without removing lines and general text formatting

Hi Everybody! First post! Totally noobie. I'm using the terminal to read a poorly formatted book. The text file contains, in the middle of paragraphs, hyphenation to split words that are supposed to be on multiple pages. It looks ve -- ry much like this. I was hoping to use grep -v " -- "... (5 Replies)
Discussion started by: AxeHandle
5 Replies

10. Shell Programming and Scripting

awk to grab data in range then search for pattern

im using the following code to grab data, but after the data in the range im specifying has been grabbed, i want to count how many instances of a particular pattern is found? awk 'BEGIN{count=0} /parmlib.*RSP/,/seqfiles.*SSD/ {print; count++ } /103 error in ata file/ END { print count }'... (3 Replies)
Discussion started by: SkySmart
3 Replies
DebianNet(3pm)						     Linux Programmer's Manual						    DebianNet(3pm)

NAME
DebianNet.pm - create, remove, enable or disable entry in /etc/inetd.conf SYNOPSIS
require DebianNet; DebianNet::add_service($newentry, $group); DebianNet::remove_service($entry); DebianNet::enable_service($service, $pattern); DebianNet::disable_service($service, $pattern); DESCRIPTION
You can use the functions in DebianNet.pm to to add, remove, enable or disable entries in the /etc/inetd.conf file. After the /etc/inetd.conf file has been changed, a SIGHUP signal will be sent to the inetd process to make sure that inetd will use the new /etc/inetd.conf file. The functions can also be used to add entries that are commented out by default. They will be treated like normal entries. That also means that if you already have an entry that is commented out you can't add an entry for the same service without remov- ing the old one first. The DebianNet functions treat entries that are commented out by a single '#' character as entries that have been commented out by a user. It won't change such entries. For shell scripts you can also use the update-inetd command. See update-inetd(8) for further information. VARIABLES
$DebianNet::inetdcf = "FILENAME"; Use FILENAME instead of /etc/inetd.conf (e.g. for testing purposes). $DebianNet::sep = "#<off># "; "#<off># " will be used as the default comment characters. You can use this option to specify different comment characters. This is only necessary if you have to deal with two (or more) services of the same name. $DebianNet::multi = "true"; If you want to disable/remove more than one entry at a time you should use this option. If you try to remove more than one entry at a time without using this option the program will show a warning and asks the user if he want to continue. $DebianNet::verbose = "true"; Explain what is being done. FUNCTIONS
DebianNet::add_service($newentry, $group); Add $newentry to the group $group of the /etc/inetd.conf file. If the entry already exist it will be enabled (it will also detect entries with different program options). Using $group is optional (the default group is the group OTHER). If the group does not exist the entry will be placed at the end of the file. DebianNet::remove_service($entry); Remove $entry from /etc/inetd.conf . You can use a regular expression to remove the entry. DebianNet::enable_service($service, $pattern); Enable $service (e.g. "ftp") in /etc/inetd.conf . Using $pattern is optional. It can be used to select a service. You only need this option if you have two (or more) services of the same name. An example: you have three ftp entries in the /etc/inetd.conf file (all disabled by default) and you want to enable the entry which uses the wu-ftpd daemon. To do this, use the pattern "wu-ftpd" (or any other regular expression that matches this entry). DebianNet::disable_service($service, $pattern); Disable SERVICE (e.g. "ftp") in /etc/inetd.conf . Using $pattern is optional (see above). AUTHORS
Peter Tobias, <tobias@et-inf.fho-emden.de> Ian Jackson <iwj10@cus.cam.ac.uk> Linux 21 September 1995 DebianNet(3pm)
All times are GMT -4. The time now is 03:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy