Grep not working on mac


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Grep not working on mac
# 1  
Old 01-15-2015
Grep not working on mac

Hi all,
I got a new mac and can't get grep, awk etc to work.

I tried the following command:

Code:
grep DICER test.txt

output:
Code:
AGOER

text.txt looks like this:

Code:
DICER
DICER
AGO

What is wrong?

Moderator's Comments:
Mod Comment Please use code tags
# 2  
Old 01-15-2015
Please show the output of

Code:
echo $PATH

# 3  
Old 01-15-2015
Code:
robinm$ echo $PATH

/usr/local/Cellar/coreutils/8.23_1/libexec/gnubin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

I installed the Homebrew package

Last edited by Scrutinizer; 01-15-2015 at 12:31 PM..
# 4  
Old 01-15-2015
Hello,
What is file format (unix,dos,mac) ?
I think file format is mac but your tools work with unix format...
examples:
Code:
$ grep DICER MAC.txt
DICER
DICER
$ unix2mac MAC.txt
unix2mac: conversion du fichier MAC.txt au format Mac...
$ grep DICER MAC.txt
AGOER

# 5  
Old 01-15-2015
I saved it as tab delimited text (.txt) from excel on mac.


I also tried another command that did not work:

Code:
sed '/^\s*$/d' Endonuclease_GO-0004519_Filter.txt

Output:

Code:
E3C5X5

DCL4
DICER
CAS1A
CAS2A
APE

T2BA
ENDOA

The empty lines remains, even if the function is supposed to remove them.
What is wrong with my files??

Last edited by Palgrave; 01-15-2015 at 10:40 AM..
# 6  
Old 01-15-2015
Post the output of od -ctx1 run on your files.
# 7  
Old 01-15-2015
Code:
Endonuclease_GO-0004519_Filter.txt | head
0000000   E   3   C   5   X   5  \r  \n  \r  \n   D   C   L   4  \r  \n
         45  33  43  35  58  35  0d  0a  0d  0a  44  43  4c  34  0d  0a
0000020   D   I   C   E   R  \r  \n   C   A   S   1   A  \r  \n   C   A
         44  49  43  45  52  0d  0a  43  41  53  31  41  0d  0a  43  41
0000040   S   2   A  \r  \n   A   P   E  \r  \n  \r  \n   T   2   B   A
         53  32  41  0d  0a  41  50  45  0d  0a  0d  0a  54  32  42  41
0000060  \r  \n   E   N   D   O   A  \r  \n   N   F   I  \r  \n   R   E
         0d  0a  45  4e  44  4f  41  0d  0a  4e  46  49  0d  0a  52  45
0000100   C   U  \r  \n   Y   O   K   F  \r  \n   Q   9   M   C   N   1
         43  55  0d  0a  59  4f  4b  46  0d  0a  51  39  4d  43  4e  31


Last edited by Corona688; 01-15-2015 at 11:33 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cat command not working to display Mac file in Ubuntu

Hi, Recently I got a .txt file from Mac user. when I try to open it in my Ubuntu machine using cat command it is not displaying any content of file however I can see the content using vi. Anyone know How to see its content using cat as I have to process it in my shell script. Thanks in... (4 Replies)
Discussion started by: diehard
4 Replies

2. Shell Programming and Scripting

GREP mac address

Hi, mac.txt My mac address is <Mac Address>. How can i replace <Mac Address> with the actual of my computer? I try to GREP command as below but i am unable to grep it to replace just <Mac Address>. ifconfig eth0 | grep -o -E '(]{1,2}:){5}]{1,2}' Million in Advance. Please use... (7 Replies)
Discussion started by: derrickyee81
7 Replies

3. Shell Programming and Scripting

pbpaste and grep with Mac X11

Hello, Here is what I am trying to do: 1) Copy a string to the pasteboard using Command-C 2) Search for the string in a file in X11. Command-C pbaste | grep - filname (does NOT work) What is the correct syntax? Thanks! (4 Replies)
Discussion started by: palex
4 Replies

4. UNIX for Dummies Questions & Answers

Grep /Awk letters X - X in every line and print it as a mac address

hey i m kinda new to this so i will appreciate any help , i have this list of values: pwwn = 0x50012482009cd7a7 nwwn=0x50012482009cd7a6 port_id = 0x280200 pwwn = 0x5001248201bcd7a7 nwwn=0x5001248201bcd7a6 port_id = 0x280300 pwwn = 0x50012482009c51ad nwwn=0x50012482009c51ac port_id =... (4 Replies)
Discussion started by: boaz733
4 Replies

5. Shell Programming and Scripting

GUI Shell Script Mac OS X - Working Directory

Hi. I'm pretty new to shell scripting. All I want to do is have a simple shell script that opens a python script from the GUI i.e. when I double click the shell script it will launch the python file. However when I try to do this it looks for the python file in my home directory, I have tried... (1 Reply)
Discussion started by: whatg
1 Replies

6. Shell Programming and Scripting

grep not working ????

Hi, I've prob in doing grep. I want to grep line staring with number 531250 in the 1st column from a file (example in picture attached below) using command grep -w "531250" file my ideal result should be 531250 1 21 42.1 100 1e-05 ... (8 Replies)
Discussion started by: masterpiece
8 Replies

7. UNIX for Dummies Questions & Answers

rm /var/db/.AppleSetupDone no longer working for mac OS X 10.6??!? HELP!!!!

My roommate forgot his admin password on his MacBook air.. He doesn't have the external SuperDrive, so we have no way of using the simple method of using the install disks and resetting the password.. The worst part is, he did this same thing about a year ago lol At the time, we booted... (0 Replies)
Discussion started by: PhiGam
0 Replies

8. OS X (Apple)

Postfix in Mac OS X 10.5 not working

I'm currently working on a project that would need to send email from my list of users. Based on the search I've done, I could send formatted email from my server using Postfix. I setup my mac adding a few lines below: /etc/hostconfig MAILSERVER=-YES- /etc/postfix/main.cf ... (1 Reply)
Discussion started by: airman_ole
1 Replies

9. UNIX for Dummies Questions & Answers

grep not working

This condition is not able to grep , can any one tell what's wrong with this part. I am able to see from unix command but not with host script. echo "Checking for Loader Status " >> $REPFILE if test $? = 0 then echo "Successful termination of SQL*Loader "$LOADER1 >>... (5 Replies)
Discussion started by: u263066
5 Replies
Login or Register to Ask a Question