Problem with output awk and sed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem with output awk and sed
# 1  
Old 01-24-2014
Problem with output awk and sed

I have file, i am extracting email address from file. but problem is that output is very ugly.

I am using this command



Moderator's Comments:
Mod Comment REMOVED "CSS OFFENDING CODE"...




While original filename have no such character. Please suggest.
# 2  
Old 01-24-2014
Quote:
Originally Posted by learnbash
I have file, i am extracting email address from file. but problem is that output is very ugly.

I am using this command

Code:
 awk {'print $1'} filename  | tr -d , > 1.txt

Below output is coming,

^@r^@e^@g^@i^@s^@t^@r^@a^@r^@@^@a^@j^@a^@.^@e^@d^@u^@.^@q^@a^@,^@
^@j^@a^@n^@e^@.^@f^@a^@b^@r^@i^@g^@a^@s^@@^@a^@k^@i^@s^@b^@s^@.^@t^@v^@,^@



While original filename have no such character. Please suggest.
show us your input and expected output.
awk usage is awk '{...code...}' file
# 3  
Old 01-24-2014
Quote:
Originally Posted by Akshay Hegde
show us your input and expected output.
awk usage is awk '{...code...}' file
I have file format like this

Code:
learnk@gmail.com, , http://www.mymail.com/files/js/js_-jenMcWHoY-_YofME9QdfIdN78Hvtfo2npip2cxdObU.js


expected output is

learnk@gmail.com

# 4  
Old 01-24-2014
I don't think this ^@r^@e^@g^@i^@s^@t^@r^@a^@r^@@^@a^@j^@a^@.^@e^@d^@u^@.^@q^@a^@,^@ is coming from nowhere, it must be in the original file, where did the file come from? If it's from Windows it may be in some odd Unicode character set.
# 5  
Old 01-24-2014
Quote:
Originally Posted by Corona688
I don't think this ^@r^@e^@g^@i^@s^@t^@r^@a^@r^@@^@a^@j^@a^@.^@e^@d^@u^@.^@q^@a^@,^@ is coming from nowhere, it must be in the original file, where did the file come from? If it's from Windows it may be in some odd Unicode character set.


Code:
One thing when i am using below command, output is coming fine
awk {'print $1'} filename  | tr -d ,

But when i am using this command 

awk {'print $1'} filename  | tr -d , > 1.txt

and opening a file in vi, i am able to see this @@@

I don't understand where the problem is
# 6  
Old 01-24-2014
Assuming first line in file contains email address

Code:
$ awk -F, '{print $1;exit}' file

# 7  
Old 01-24-2014
Quote:
Originally Posted by Akshay Hegde
Assuming first line in file contains email address

Code:
$ awk -F, '{print $1;exit}' file

I ran the command and see the output, i ran command in the terminal

Code:
# awk -F, '{print $1;exit}' output-save-2014-01-24-1.txt 
��klaus.har33@abcd.com

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem in formatting output in sed / awk

I have a file like this : ! 1 ! 542255 ! 50,140.00 ! ! 2 ! 551717 ! 5,805.00 ! ! 3 ! 551763 ! 8,130.00 ! ! 4 ! 551779 ! 750.00 ! ! 5 ! 551810 ! 56,580.00 ! ! 6 ! 551816 ! 1,350.00 ! ! 7 ! 551876 ! 360.00 ! ! 8 ! 551898 ! ... (10 Replies)
Discussion started by: adam1969in
10 Replies

2. Shell Programming and Scripting

Output on one line using awk or sed

I have a file of 100,000 lines in the below format: answer.bed chr1 957570 957852 NOC2L chr1 976034 976270 PERM1 chr1 976542 976787 PERM1 I need to get each on one line and so far what I have tried doesn't seem to be working. Thank you... (3 Replies)
Discussion started by: cmccabe
3 Replies

3. Shell Programming and Scripting

Use of awk/sed to filter out fdisk output

Hi , I am trying to filter out the below output of fdisk -l command : fdisk -l Disk /dev/sda: 42.9 GB, 42949672960 bytes 255 heads, 63 sectors/track, 5221 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 ... (9 Replies)
Discussion started by: omkar.jadhav
9 Replies

4. Shell Programming and Scripting

Pipe awk's output to sed for deletion

Hi Friends, I am using a command that prints certain lines from a file. For ex: cat input abc chr1 456 def chr1 789 ghi chr1 999 jjj chr1 777 jhk chr7 914 My command awk '{if($2=="chr1" && $3>=456 && $3<=999) {print $0}}' OFS="\t" input Output being printed is abc chr1 456 (7 Replies)
Discussion started by: jacobs.smith
7 Replies

5. Shell Programming and Scripting

need awk or sed help to reformat output

We have the following output: server1_J00_data_20120711122243 server1_J00_igs_20120711122243 server1_J00_j2ee_20120711122243 server1_J00_sec_20120711122243 server1_J00_data_20120711131819 server1_J00_igs_20120711131819 server1_J00_j2ee_20120711131819 server2_J00_data_20120711122245... (10 Replies)
Discussion started by: ux4me
10 Replies

6. UNIX for Dummies Questions & Answers

Appending columns at the end of output using awk/sed

Hi , I have the below ouput, =====gopi===== assasassaa adsadsadsdsada asdsadsadasdsa sadasdsadsd =====kannan=== asdasdasd sadasddsaasd adasdd =====hbk=== asasasssa .... .. I want the output like as below, not able paste here correctly. (2 Replies)
Discussion started by: eeegopikannan
2 Replies

7. UNIX for Advanced & Expert Users

Using awk or sed need the output in the new file

Please find the input file as given below: 2012/02/29 11:00:00~~CRITICAL~For customer 00000476 no daily files were found in the 010137933 account directory. 2012/02/29 11:00:00~~CRITICAL~For customer 05006802 no daily files were found in the 010115166 account directory. 2012/02/29... (0 Replies)
Discussion started by: av_sagar
0 Replies

8. UNIX for Dummies Questions & Answers

awk output problem

Hi Gurus, I have a file which has some fields separated with multiple spaces or single space. data 1 2 3 4 5 6 4 5 5 7 7 8 9 4 6 10 and so on..... The problem I am facing is the output of the awk program... (2 Replies)
Discussion started by: sanjay.login
2 Replies

9. Shell Programming and Scripting

Awk & sed query for output

Hello, I have a file. its content are like below. mdn:87439842 imsi:23082038203 Ctime:12082010 01:20:10 mdn:9324783783 imsi:402349823322 Ctime: 12072010 01:20:10 mdn:87439842 imsi:23082038203 Ctime: 23072010 01:20:10 mdn:87439842 imsi:23082038203 Ctime:18072010 01:20:10 mdn:87439842... (3 Replies)
Discussion started by: Sanket11
3 Replies

10. UNIX for Dummies Questions & Answers

using awk or sed to print output from one file

dear i have one file regarding >abshabja>sdksjbs>sknakna>snajxcls so i want to be output like >abshabja >sjkabjb >sknakna >snajxcls Any using awk or sed will help thanks (2 Replies)
Discussion started by: cdfd123
2 Replies
Login or Register to Ask a Question