Cat command not working to display Mac file in Ubuntu


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Cat command not working to display Mac file in Ubuntu
# 1  
Old 12-30-2014
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 Advance.
# 2  
Old 12-30-2014
When you use vi, do you see a regular ASCII file or something else?
# 3  
Old 12-30-2014
At the bottom left it is [mac] and at the right side bottom it is ALL written in vi.

---------- Post updated at 11:34 AM ---------- Previous update was at 11:33 AM ----------

May be I should use dos2unix or recode or iconv but I am not sure about it.
# 4  
Old 12-30-2014
I don't think dos2unix would work, as it is mac to unix.
I guess it contains short lines only? Due to the <CR> line terminator, it will print all lines into the current line, overwriting the recent lines, and then finally overwrite that with your command prompt. Try tr '\r' '\n' < file.txt
This User Gave Thanks to RudiC For This Post:
# 5  
Old 12-31-2014
Thanks Now I got it. With your command I can put the content of file in some temp file before opening it with cat.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Simple sed command not working; could be a Mac/Linux vs. PC/Linux issue

Hello, I am on a Mac and trying to clean up some monthly files with a very simple SED: sed '3,10d;/<ACROSS>/,$d' input.txt > output.txt (from the input, delete lines 3 - 10; then delete from the line containing <ACROSS> to the end of the file) then output to output.txt Even when I try... (2 Replies)
Discussion started by: verbatim
2 Replies

2. UNIX for Advanced & Expert Users

Working with configure file in ubuntu

Hi, I want to add the library in my configure file. i am doing it using autoconf in ubuntu. I am new to the autoconf. Can anyone please let me know how to add the library using configure file so that it can linked to my software which I am using? Thanks in advance!!!!! (0 Replies)
Discussion started by: diehard
0 Replies

3. Shell Programming and Scripting

sed command works on Fedora/Ubuntu, but doesn't work in Mac

Hi, I have a question. I define a function using sed command: replace() { searchterm=$1 replaceterm=$2 sed -e "s/$searchterm/$replaceterm/ig" $3 > $WORK'tempfile.tmp' mv $WORK'tempfile.tmp' $3 } Then I call replace 'test = 0' 'test = 1' $myfile This code... (1 Reply)
Discussion started by: Dark2Bright
1 Replies

4. Shell Programming and Scripting

sed command works on Fedora/Ubuntu, but doesn't work in Mac

Hi, I have a question. I define a function using sed command: replace() { searchterm=$1 replaceterm=$2 sed -e "s/$searchterm/$replaceterm/ig" $3 > $WORK'tempfile.tmp' mv $WORK'tempfile.tmp' $3 } Then I call replace 'test = 0' 'test = 1' $myfileThis code works well in... (1 Reply)
Discussion started by: Dark2Bright
1 Replies

5. UNIX for Dummies Questions & Answers

Creating File using the CAT Command

Hello , I am newbie to UNIX platform . I have read that there are two ways of creating files that is using 1.) Cat 2.) touch . With Cat Command i am unable to create a File , i is saying No file or Directory exists I logged in with root as user . please help (7 Replies)
Discussion started by: Ravi Pavanv
7 Replies

6. OS X (Apple)

Cat command not working as expected

I've been trying to figure this out since last night, and I'm just stumped. The last time I did any shell scripting was 8 years ago on a Unix box, and it was never my strong suit. I'm on a Mac running Leopard now. Here's my dilemma - hopefully someone can point me in the right direction. I'm... (10 Replies)
Discussion started by: Daniel M. Clark
10 Replies

7. Shell Programming and Scripting

cat in the command line doesn't match cat in the script

Hello, So I sorted my file as I was supposed to: sort -n -r -k 2 -k 1 file1 | uniq > file2 and when I wrote > cat file2 in the command line, I got what I was expecting, but in the script itself ... sort -n -r -k 2 -k 1 averages | uniq > temp cat file2 It wrote a whole... (21 Replies)
Discussion started by: shira
21 Replies

8. UNIX for Dummies Questions & Answers

grep/cat/more -- search in a txt file and display content from a specific "keyword"

Hi, I have a .txt file Sample: ===================== NEXT HOST ===================== AEADBAS001 ip access-list extended BLA_Incoming_Filter ip access-list extended BLA_Outgoing_Filter access-list 1 permit xxxxxxxxxxxxxx access-list 2 permit xxxxxxxxxxxxxx =====================... (4 Replies)
Discussion started by: I-1
4 Replies
Login or Register to Ask a Question