Sponsored Content
Top Forums Shell Programming and Scripting Remove single @ on line from file Post 303035206 by joeg1484 on Thursday 16th of May 2019 11:49:48 AM
Old 05-16-2019
Remove single @ on line from file

Hi All,


So I have to remove all the @hostnames from a file, the problem is, there are instances where @ is used for other things... For example:


example text:
Code:
@This is some text in between some at signs@
@This is some more text@
This is a line that will contain a username and his/her email - me@somehost.com
This is another email line - you@anotherhost.com

I need to remove the text after the @somehost.com and @anotherhost.com but leave the two previous @ bla bla bla @ lines.


Heres what I have tried:


Code:
cat * |egrep -v '@.*@'|sed 's/@.*/@REDACTED/'

This kind of works, but I need all the lines intact


Code:
sed 's/@.*/@REDACTED/'

This just removed all the test after the @. This would be ok, but we would like to have the other lines if possible - we do just want to secure the file from having hostnames.



Not sure how to accomplish this. Any advice would be appreciated.


Thanks!
Joe
 

10 More Discussions You Might Find Interesting

1. Programming

remove single-line comment

Does anyone knows how to write a program to remove single-line comment in C program? that means it don't read anything behind // (3 Replies)
Discussion started by: Icy002
3 Replies

2. UNIX for Dummies Questions & Answers

Trying to remove single character from a line

Here is a sample code grep '903' -i user.txt | tail -2 | awk '{print $2}' | sed 's/B//g' the input file has data as such 903-xxx-xxxxB 903-xxx-xxxxB It is a dialer file i want to remove the "B" any help thanks (5 Replies)
Discussion started by: Iz3k34l
5 Replies

3. UNIX for Dummies Questions & Answers

how to remove mutilple enrty in a single line in unix

Hi, Below is a single line output. subsD,01 02 03 04 05 00 00 00 00 07 00 05,hlr,common,00000000 subsD,01 02 03 04 05 00 00 00 00 07 00 05,hlr,01,baoc|notActive|notInduced,activeAndOperative,notActive,notActive,noneDesignated,0,notActive|00|,notActive|00|,notActive|00|,notActive|00|30|,,... (4 Replies)
Discussion started by: kaprus
4 Replies

4. Shell Programming and Scripting

Need to remove multiple text from a single file

Dear all, I have a file which have let us say records from A-Z. Now I want to remove multiple letter from this file using single command.. let us say I want to remove A,F,K,Y,U,P,B,S,D. I can use grep -v command but for this case i need to rerun the file several time i wana avoid using... (3 Replies)
Discussion started by: jojo123
3 Replies

5. Shell Programming and Scripting

awk concatenate every line of a file in a single line

I have several hundreds of tiny files which need to be concatenated into one single line and all those in a single file. Some files have several blank lines. Tried to use this script but failed on it. awk 'END { print r } r && !/^/ { print FILENAME, r; r = "" }{ r = r ? r $0 : $0 }' *.txt... (8 Replies)
Discussion started by: sdf
8 Replies

6. Shell Programming and Scripting

Formatting File having big single line into 95 Char Per Line

Hi All, I have 4 big files which contains one big line containing formatted character records, I need to format each file in such way that each File will have 95 Characters per line. Last line of each file will have newline character at end. Before:- File Name:- File1.dat 102 121340560... (10 Replies)
Discussion started by: lancesunny
10 Replies

7. UNIX for Dummies Questions & Answers

Remove multi line and single line comments

Hi, I am trying to remove multi line and single line comments like examples below I have tried this pattern. it works fine for single line comments and multi line comments in a single line only. but this fails when the comments are extended in multiple lines as shown in the comment 2 of... (3 Replies)
Discussion started by: ahmedwaseem2000
3 Replies

8. UNIX for Dummies Questions & Answers

To find and display the middle line in a file using single line command.

Hi all, How can i display the middle line of a file using a single line command? (6 Replies)
Discussion started by: Lakme Pemmaiah
6 Replies

9. UNIX for Beginners Questions & Answers

Output to file print as single line, not separate line

example of problem: when I echo "$e" >> /home/cogiz/file.txt result prints to file as:AA BB CC I need it to save to file as this:AA BB CC I know it's probably something really simple but any help would be greatly appreciated. Thank You. Cogiz (7 Replies)
Discussion started by: cogiz
7 Replies

10. Shell Programming and Scripting

Remove single-line breaks only in document

Regarding copy/pasted text of copyright-free book from archive.org (link below), in attempt to expand single-line-break paragraph text (not section headings or paragraph breaks) to wider right margin, Justify or Wrap in LIbreOffice is not working, and Find/Replace the paragraph mark ($) wraps all... (2 Replies)
Discussion started by: p1ne
2 Replies
remove element(1m)														remove element(1m)

NAME
remove element - Removes selected elements from a profile SYNOPSIS
rpccp remove element profile-entry-name {-d | -i if-id -m member | -a annotation} [-s syntax] OPTIONS
Removes the default profile element. With the -d option, the -a, -i, and -m options are ignored. Defines an interface identifier for the profile element to be removed for a member specified with the -m option. Only one interface and member pair can be removed in a single operation. If you supply multiple instances of the -i option, the command uses the final instance. The -i and -m options take precedence over the -a option. However, if the default profile element is specified (by the -d option), the -i and -m options are ignored. The interface identifier value has the following form: interface-uuid,major-version.minor-version The UUID is a hexadecimal string and the version numbers are decimal strings, for example: -i ec1eeb60-5943-11c9-a309-08002b102989,1.1 Leading zeros in version numbers are ignored. Defines a member name for the profile element to be removed. This option is required if the interface identifier is specified. Only one interface and member can be removed in a single operation. If you supply multiple instances of the -m option, the command uses the final instance. Removes all elements whose annotation fields match the specified annotation; in the presence of -d option or -i and -m options, the -a option is ignored. Note that the shell supports quotation marks around the annotation field of profile elements, which allows you to include internal spaces in an annotation; the control program does not. To specify or refer to annotations from within the control program, limit each annotation to an unbroken alphanumeric string; for example, CalendarGroup. To refer to annotations from the system prompt, do not incorporate quota- tion marks into any annotation. Indicates the name syntax of the entry name (optional). The only value for this option is the dce name syntax, which is the default name syntax. Until an alternative name syntax becomes available, specifying the -s option is unnecessary. ARGUMENTS
Indicates the name of the target profile. For an entry in the local cell, you can omit the cell name and specify only the cell-relative name. DESCRIPTION
The remove element command removes an element from a profile in the name service database. For a description of the fields in a profile element, see add entry(1m). The remove element command requires the entry name of the profile. The command also requires one of the following options: The default pro- file option takes precedence over the other two options. interface-id -m member-name An interface and member pair takes precedence over the -a option. The annotation option takes effect only if neither the -d or -i option is specified. Privilege Required You need read permission and write permission to the CDS object entry (the target profile entry). NOTE
This command is replaced at Revision 1.1 by the dcecp command and may not be provided in future releases of DCE. EXAMPLES
The initial shell commands set up an environment variable Calendar_1_1, which represents the interface identifier of an RPC interface. The control program commands set up an environment variable for the interface identifier of the Calendar Version 1.1 RPC interface, run RPCCP, and remove an element from a profile, as follows: $ Calendar_1_1=ec1eeb60-5943-11c9-a309-08002b102989,1.1 $ export Calendar_1_1 $ rpccp rpccp> remove element -i Calendar_1_1 > -m /.:/LandS/anthro/Calendar_group > /.:/LandS/anthro/molly_o_profile RELATED INFORMATION
Commands: add element(1m), remove profile(1m), show profile(1m) remove element(1m)
All times are GMT -4. The time now is 06:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy