Sponsored Content
Top Forums Shell Programming and Scripting Delete a pattern including any whitespace before it and after it Post 303042651 by RudiC on Thursday 2nd of January 2020 04:16:45 AM
Old 01-02-2020
@Aia: the problem with your approach is that
- either ALL multiple spaces in the string are reduced to a single one (if unquoted)
- or the spaces around A_PATTERN are preserved (if quoted), which was not what the OP requested.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find files including subdirectory and Delete

Hello Experts, I m newbie. Could u pls help me to write script on Sun solaris- I have backup directory "/var/opt/backup/" where files are backed up in different directory "backup1" "backup2" "backup3". I want to write a shell script which i will put in crontab and daily midnight it will... (1 Reply)
Discussion started by: thepurple
1 Replies

2. Shell Programming and Scripting

Delete whitespace

Hi, I have been trying to remove whitespace from a file using sed. Here is an example of what im trying to do: www1 = www1 www2 = www2 www3 = www3 and all the way to 300 and i want it to look like: www1=www1 www2-www2 www3=www3 again upto 300 Any help... (12 Replies)
Discussion started by: truck7758
12 Replies

3. Shell Programming and Scripting

sed: Find start of pattern and extract text to end of line, including the pattern

This is my first post, please be nice. I have tried to google and read different tutorials. The task at hand is: Input file input.txt (example) abc123defhij-E-1234jslo 456ujs-W-abXjklp From this file the task is to grep the -E- and -W- strings that are unique and write a new file... (5 Replies)
Discussion started by: TestTomas
5 Replies

4. Shell Programming and Scripting

How to match (whitespace digits whitespace) sequence?

Hi Following is an example line. echo "192.22.22.22 \"33dffwef\" 200 300 dsdsd" | sed "s:\(\ *\ \):\1:" I want it's output to be 200 However this is not the case. Can you tell me how to do it? I don't want to use AWK for this. Secondly, how can i fetch just 300? Should I use "\2"... (3 Replies)
Discussion started by: shahanali
3 Replies

5. Shell Programming and Scripting

Search for Pattern and Print including Lines in between

Gurus, I have a big file that needs to be sorted out and I cant figure out what to do. The file name is as below: Name: xxxx yyyy nnnn Description: dfffgs sdgsgsf hsfhhs afgghhjdgj fjklllll gsfhfh Updated: jafgadsgg gsg Corrected: date today The file consists of line like these. ... (13 Replies)
Discussion started by: The One
13 Replies

6. Shell Programming and Scripting

remove contents including the tag if pattern matches

Hi all, Can anyone help me on this. I have several WP sites that are affected by sql injections. But the contents are different as follows western union india belgaum western union india bolegaon western union india barhaj western union india budhana western union india belda western... (6 Replies)
Discussion started by: sanjuabraham
6 Replies

7. UNIX for Dummies Questions & Answers

delete trailing whitespace from end of each line in column 1 only

Hi All. How can I convert this: ABC_1_1 ABC_1_2 ABC_1_3 into this: ABC_1 1 ABC_1 2 ABC_1 3 I tried this command but it is not working: awk '{sub(/+$/,"\t", $1)}{print}' Any suggestions on how to fix this? Thank you :wall: Please use code tags when posting data and... (3 Replies)
Discussion started by: danieladna
3 Replies

8. Shell Programming and Scripting

Including EOL in egrep pattern for multiple lines

Hi all I need your help to get a high-performance solution. I am working on a extensive script to automate file restores using the bprestore tool on a Solaris 5.10 server (bash 3.00). I will only paste the needed parts of the script to avoid any confusion. To use the script the user has to... (2 Replies)
Discussion started by: Anonym
2 Replies

9. Shell Programming and Scripting

How to use ls with pattern and including path?

Hello to all, Maybe someone could help me, my question is: How can a filter the print of command ls for the files with names of the form "abc*.txt" including the path? I've done this: If I move with command cd to /My/Path/Is/This/ and send this command: ls -lst abc*.txt -i... (37 Replies)
Discussion started by: Ophiuchus
37 Replies

10. Shell Programming and Scripting

How to extract/delete lines including 0%?

Hello, I have a data file consisting of many lines and my target is to delete all lines containing 0% After some sed processes, I convert it to shown below format: Sample webpage logfile: Expected output is: sed command is not working for below methods: sed -n '/0%/p' logfile > output... (1 Reply)
Discussion started by: baris35
1 Replies
PCRE_TABLE(5)							File Formats Manual						     PCRE_TABLE(5)

NAME
pcre_table - format of Postfix PCRE tables SYNOPSIS
pcre:/etc/postfix/filename DESCRIPTION
The Postfix mail system uses optional tables for address rewriting or mail routing. These tables are usually in dbm or db format. Alterna- tively, lookup tables can be specified in Perl Compatible Regular Expression form. To find out what types of lookup tables your Postfix system supports use the postconf -m command. The general form of a PCRE table is: pattern result When pattern matches a search string, use the corresponding result. blank lines and comments Empty lines and whitespace-only lines are ignored, as are lines whose first non-whitespace character is a `#'. multi-line text A logical line starts with non-whitespace text. A line that starts with whitespace continues a logical line. Each pattern is a perl-like regular expression. The expression delimiter can be any character, except whitespace or characters that have special meaning (traditionally the forward slash is used). The regular expression can contain whitespace. By default, matching is case-insensitive, although following the second slash with an `i' flag will reverse this. Other flags are sup- ported, but the only other useful one is `U', which makes matching ungreedy (see PCRE documentation and source for more info). Each pattern is applied to the entire lookup key string. Depending on the application, that string is an entire client hostname, an entire client IP address, or an entire mail address. Thus, no parent domain or parent network search is done, and user@domain mail addresses are not broken up into their user and domain constituent parts, nor is user+foo broken up into user and foo. Patterns are applied in the order as specified in the table, until a pattern is found that matches the search string. Substitution of substrings from the matched expression into the result string is possible using the conventional perl syntax ($1, $2, etc.). The macros in the result string may need to be written as ${n} or $(n) if they aren't followed by whitespace. EXAMPLE SMTPD ACCESS MAP
# Protect your outgoing majordomo exploders /^(?!owner-)(.*)-outgoing@/ 550 Use ${1}@${2} instead # Bounce friend@whatever, except when whatever is our domain (you would # be better just bouncing all friend@ mail - this is just an example). /^friend@(?!my.domain)/ 550 Stick this in your pipe $0 # A multi-line entry. The text is sent as one line. # /^noddy@my.domain$/ 550 This user is a funny one. You really don't want to send mail to them as it only makes their head spin. EXAMPLE HEADER FILTER MAP
/^Subject: make money fast/ REJECT /^To: friend@public.com/ REJECT SEE ALSO
regexp_table(5) format of POSIX regular expression tables AUTHOR(S) The PCRE table lookup code was originally written by: Andrew McNamara andrewm@connect.com.au connect.com.au Pty. Ltd. Level 3, 213 Miller St North Sydney, NSW, Australia Adopted and adapted by: Wietse Venema IBM T.J. Watson Research P.O. Box 704 Yorktown Heights, NY 10598, USA PCRE_TABLE(5)
All times are GMT -4. The time now is 02:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy