Visit Our UNIX and Linux User Community

Need to strip few letters

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need to strip few letters
# 1  
Old 03-10-2008
Need to strip few letters

Hey guys..

Can experts help me in achieving my purpose..

I have a file which contains email address of some 100 to 1000 domains, I need only the domain names..


The output should contain only

Thanks in Advance...
# 2  
Old 03-10-2008
if that sample is all you have,
awk -F"@" '{.....}' file

cut -d "@" -f ....  file

or in shell
while IFS="@" read -r a b
done < "file"

# 3  
Old 03-11-2008
cat temp.txt | perl -pe 's/^.*@(.*)$/$1/'

This will handle the sample lines you provided.
# 4  
Old 03-11-2008
And a sed one

$ sed 's/\(.*\)@\(.*\)/\2/' email.txt

# 5  
Old 03-11-2008
Originally Posted by ShawnMilo
cat temp.txt | perl -pe 's/^.*@(.*)$/$1/'

This will handle the sample lines you provided.
forget the cat.
perl -pe 's/^.*@(.*)$/$1/' temp.txt

# 6  
Old 03-11-2008
I always use the cat, although it's unnecessary. It adds uniformity. Some people feel the need to use as few characters as possible, or to spare the processor the extra load. But others (me included) see the cat as a convenient way to add clarity. To each his own.

I also get yelled at by my friends for usually using "sort | uniq" instead of "sort -u." Because I so often use "sort | uniq -cd" or pipe to "wc -l," it's a lot easier to always type it the same way. Also it adds clarity. The power in all the tiny tools on a *nix box is that they can be strung together to do amazingly complex tasks. It is not (and should not be) the goal of any one program to overreach and try to do too much.

However, you're correct about the cat and my friends are correct about the sort -u. I just prefer to do it my way. Stubborn, I guess. At least I finally started using CTRL+R instead of piping the history command through a grep. Usually...


Previous Thread | Next Thread
Test Your Knowledge in Computers #777
Difficulty: Easy
The Fourier transform can be formally defined as an improper Riemann integral.
True or False?

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Strip First few Characters

I want to strip first few characters from each record until a proper datesamp is found. Request for getNextPage.................06/29/12 07:49:30 VVUKOVIC@{7A805FEF76A62FCBB23EA78B5380EF95.tomcat1}TP-Processor14 LogExchUsage: ERROR:: isprof=false : exch=NSDQ output should be... (2 Replies)
Discussion started by: ratheeshjulk
2 Replies

2. Solaris

strip error

Hi I am getting the below error while using strip command. strip: libelf error. Request error: no string table strip: a.out: file not manipulated Could somebody please let me know what might be the solution?? It is in ksh and solaris 10. Thanks in advance (4 Replies)
Discussion started by: vali__
4 Replies

3. Shell Programming and Scripting

Strip out the string

awk -F"\t" -vOFS="\t" '{print $1"\t-\t-","",$6,$7"\t-"$8"\t-\t-\t"$15}' file.tsv > output.tsv Using the above command how to remove the string from the $7 value. (7 Replies)
Discussion started by: sandy1028
7 Replies

4. Shell Programming and Scripting

Strip a string in sh

I have a list of servers that I need my script to ping however this list also has the env they belong too such as SIT, PRD, warehouse and so on. The break character for each section is : A value in my list would look like this... Where is... (13 Replies)
Discussion started by: LRoberts
13 Replies

5. Programming

Strip command

I am new in Unix. I go through the man strip. But did not understand that, why when we have -G (debug and release ) option in the compiler, than using strip command to strip the debug information from the objects. i want to binary for teh production i will compile it without debug option. What the... (4 Replies)
Discussion started by: Saurabh78
4 Replies

6. UNIX for Advanced & Expert Users

strip command

I have created one binary with the debug option debug.out and another without it is production.out. Now, i use stripe on the debug.out. Now, both binary will be same? or have any differences. (1 Reply)
Discussion started by: Saurabh78
1 Replies

7. Shell Programming and Scripting

Need to strip a string

I have a file that looks like this: /home/fred/opt/bin /opt/usr/bin /usr/sbin/var/opt I need a way to chop of everything after the last occurance of the / sign including the /. So the file above will now look like this below. /home/fred/opt /opt/usr /usr/sbin/var I tried using... (6 Replies)
Discussion started by: x96riley3
6 Replies

8. Shell Programming and Scripting

Strip all non-alphanumerics

Hi, Can someone let me know how do I strip out any non-alphanumeric character in string tomake it alphanumeric? i.e abc def ghi ->abcdefghi abc-def-ghi ->abcdefghi abc#def-ghi->abcdefghi Thanks in advance (3 Replies)
Discussion started by: braindrain
3 Replies

9. Shell Programming and Scripting

How to strip strins

Guys, Please can someone tell me how to strip each string from the following ? TABLE1||METHOD||TYPE||STATUS||DATE What i need is to assign each value to the variable TABLE1 to var1 METHOD to var2 and so on If there is NULL in one of them, something like A||B||||C|| I want the... (14 Replies)
Discussion started by: kamathg
14 Replies

Featured Tech Videos