04-28-2013
Using sed, awk or perl to remove substring of all lines except the first
Greetings All,
I would like to find all occurences of a pattern and delete a substring from the all matching lines EXCEPT the first. For example:
1234::group:user1,user2,user3,blah1,blah2,blah3
2222::othergroup:user9,user8
4444::othergroup2:user3,blah,blah,user1
1234::group3:user5,user1
This should be for all combinations of gid and user. If this can be accomplished using a sed or awk one liner that would be great. Otherwise, I guess I'll try a Perl script.
Any ideas to get me started will be greatly appreciated. I'm thinking a nested for loop with an internal sed call would be a start.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I have searched the forum for this - forgive me if I missed a previous post.
I have the following file:
blah blah blah
blah blah blah
blah blah blah
blah blah blah
blah blah blah
alter table "informix".esc_acct add constraint (foreign key (fi_id)
references "informix".fi ... (5 Replies)
Discussion started by: Shoeless_Mike
5 Replies
2. Shell Programming and Scripting
Hi guys,
I need to remove the pattern (ID=180), one line before and four lines after.
Thanks. (5 Replies)
Discussion started by: ashimada
5 Replies
3. Shell Programming and Scripting
Hi Everyone,
# cat 1
a
b b
cc
1
2
3 3 3
4
55 5
a
b (2 Replies)
Discussion started by: jimmy_y
2 Replies
4. Shell Programming and Scripting
Input:
3456 565
656 878
235 8
4 8787
3 7
35 878
Expected output:
3456 565
656 878
235 8
4 8787
3 7
35 878
How can i do this with awk,sed and perl? (10 Replies)
Discussion started by: cola
10 Replies
5. Shell Programming and Scripting
Input:
hello hello
hello hello
monkey
donkey
hello hello
drink
dance
drink
Output should be:
hello hello
monkey
donkey
drink
dance (9 Replies)
Discussion started by: cola
9 Replies
6. Shell Programming and Scripting
Hi, I'm writing a ksh script and trying to use an awk / sed / or perl one-liner to remove the last 4 characters of a line in a file if it begins with a period.
Here is the contents of the file... the column in which I want to remove the last 4 characters is the last column. ($6 in awk). I've... (10 Replies)
Discussion started by: right_coaster
10 Replies
7. Shell Programming and Scripting
hi..
i have a fasta file with the following format
>sequence1
CCGGTTTTCGATTTGGTTTGACT
>sequence2
AAAGTGCCGCCAGGTTTTGAGTGT
>sequence3
AGTGCCGCAGAGTTTGTAGTGT
Now, i want to read alternate line and add "GGGGGGGGGGG" to end of every sequence
Desired output:
>sequence1... (4 Replies)
Discussion started by: empyrean
4 Replies
8. Shell Programming and Scripting
OSX
I have been grinding my teeth on a portion of code. I am building a bash script that edits a html email template. In the template, I have place holders for SED (or whatever program is appropriate) to use as anchors for find and replace, with user defined corresponding html code. The HTML code... (3 Replies)
Discussion started by: sudo
3 Replies
9. Shell Programming and Scripting
Dear group,
I have following input text file:
Brit 2016 11 18 12 00 10 1.485,00 EUR
Brit 2016 11 18 12 00 10 142,64 EUR
Brit 2016 11 18 12 00 10 19,80 EUR
Brit 2016 11 18 12 00 10 545,00 EUR
Brit 2016 11 18 12 00 10 6.450,00 EUR... (3 Replies)
Discussion started by: gfhsd
3 Replies
10. UNIX for Beginners Questions & Answers
In the awk piped to sed below I am trying to format file by removing the odd xxxx_digits and whitespace after, then move the even xxxx_digit to the line above it and add a space between them. There may be multiple lines in file but they are in the same format. The Filename_ID line is the last line... (4 Replies)
Discussion started by: cmccabe
4 Replies
LEARN ABOUT DEBIAN
calife.auth
CALIFE.AUTH(5) BSD File Formats Manual CALIFE.AUTH(5)
NAME
calife.auth -- format of the calife authorization file
DESCRIPTION
The calife.auth files are files consisting of newline separated records, one per user, containing three colon (``:'') separated fields.
These fields are as follows:
name User's login name / @group.
shell User's shell
user1,user2,...,usern
List of logins allowed for the user name
The name field is the login used to access the computer account.
The login name must never begin with a hyphen (``-''); also, it is strongly suggested that neither upper-case characters or dots (``.'') be
part of the name, as this tends to confuse mailers. No field may contain a colon (``:'') as this has been used historically to separate the
fields in the user database.
One alternative syntax is to use @group to specify that any user in the given group is allowed to use calife to become root.
The shell field is the command interpreter the user prefers. If there is nothing in the shell field, the user's current shell as found in
the (/etc/passwd) file is assumed.
If the shell field is '*', then the account is considered as locked and access is denied.
If the third parameter is specified, it is assumed to be the list of login the current user has the right to become. It enables use of calife
for non-root only accounts.
calife.auth is placed in /etc.
EXAMPLE
# calife.auth-dist
#
# Format
#
# name[:shell_to_be_run][:user1,user2,usern]
#
fcb
roberto:/bin/tcsh
pb::guest,blaireau
SEE ALSO
calife(1), su(1)
HISTORY
A calife.auth file format appeared in DG/UX and SunOS, written for Antenne 2 in 1991. It has evolved with the extra shell specification. The
login list was reintroduced in 2.7.
AUTHOR
Ollivier Robert <roberto@keltia.frmug.fr.net>
BSD
September 25, 1994 BSD