I am having trouble finding the right string for this - I dont know whether to use awk or sed..
If I have a file with alot of names and phone numbers like this
And I want to print just the line with the 603 area code plus remove all area codes int he final output sorted alpha by last name - how would I do it?
would I need to define a character set?
Moderator's Comments:
Please use code tags when posting data and code samples!
Last edited by vgersh99; 05-05-2011 at 04:45 PM..
Reason: code tags, please!
hi,
i'm trying to erase all the characters after, and including, the first test test
Output: test1 test2 test3
this is what I tried, but didn't work
sed "s/*//" file > testfilename
any suggestions?
thanks,
gammmaman (2 Replies)
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)
I been trying to get this right. I have trying to get rid of spaces in between the character < and the character >. Everytime I try, sed gets too greedy and do the whole line.
Ex.
< T AG 1> Hello, how are you doing?
<Tag 2> I am doing fine.
I want this:
<TAG1> Hello, how are you... (6 Replies)
Hello
I have a document and in this document I have several occurrence of "VAR == xxxxxxx" and xxxxx can be anything. I don't know what it is. I want to replace the 'xxxxx's with something I know.
What I know however, is the line numbers of the VAR =='s in the file.
How can I replace... (1 Reply)
I am working with bash on HP-UX server at school.
As practice for scripting, I am trying to make a pretend server admin script that adds a user to the system, deletes a user from the system, and lists all users of the pretend system. I have accomplished this with a select loop. Adding users, and... (2 Replies)
Hi gurus,
I'd like to change this complete line on a file:
BAN_COMMAND="/etc/apf/apf -d $ATTACK_HOST {bfd.$MOD}"
to this one:
BAN_COMMAND="/sbin/iptables -A INPUT -s $ATTACK_HOST -j DROP"
I've tried a lot without any successful . :(
thanks in advance
Israel. (2 Replies)
Greetings everyone. Right now I am working on a script to be used during automated deployment of servers. What I have to do is remove localhost.localdomain and localhost6.localdomain6 from the /etc/hosts file. Simple, right? Except most of the examples I've found using sed want to delete the entire... (4 Replies)
Hello Friends, How can I remove the last two values of this line using sed
John Carey:507-699-5368:29 Albert way, Edmonton, AL 25638:9/3/90:45900
The result should look like this:
John Carey:507-699-5368:29 Albert way, Edmonton, AL 25638 (3 Replies)
All:
Can somebody help me out with a sed command, which removes the the first occurance of ')' until the end of the line
If I have the following input
... (5 Replies)
Hello Friends
I want to use sed command to pick a part of line. FOr example I only need the
/home_put1/bidds/myfo
part of following line
fish://ulavet@rits1.ula.com.tr/home_put1/bidds/myfo
How can I do this bu using sed command ? (2 Replies)
Perl::Critic::Policy::RegularExpressions::RequireLineBouUseryContributed PPerl::Critic::Policy::RegularExpressions::RequireLineBoundaryMatching(3)NAME
Perl::Critic::Policy::RegularExpressions::RequireLineBoundaryMatching - Always use the "/m" modifier with regular expressions.
AFFILIATION
This Policy is part of the core Perl::Critic distribution.
DESCRIPTION
Folks coming from a "sed" or "awk" background tend to assume that '$' and '^' match the beginning and end of the line, rather than then
beginning and end of the string. Adding the '/m' flag to your regex makes it behave as most people expect it should.
my $match = m{ ^ $pattern $ }x; #not ok
my $match = m{ ^ $pattern $ }xm; #ok
CONFIGURATION
This Policy is not configurable except for the standard options.
NOTES
For common regular expressions like e-mail addresses, phone numbers, dates, etc., have a look at the Regexp::Common module. Also, be
cautions about slapping modifier flags onto existing regular expressions, as they can drastically alter their meaning. See
<http://www.perlmonks.org/?node_id=484238> for an interesting discussion on the effects of blindly modifying regular expression flags.
AUTHOR
Jeffrey Ryan Thalhammer <jeff@imaginative-software.com>
COPYRIGHT
Copyright (c) 2005-2011 Imaginative Software Systems. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license
can be found in the LICENSE file included with this module.
perl v5.16.32014-0Perl::Critic::Policy::RegularExpressions::RequireLineBoundaryMatching(3)