The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
remove blank lines in *.srt file :) hungbp UNIX for Dummies Questions & Answers 10 02-16-2008 08:40 AM
How to get last non-blank line? tqlam Shell Programming and Scripting 6 01-17-2008 07:13 PM
To remove Continous blank spaces from a file in UNIX arunkumar_mca UNIX for Dummies Questions & Answers 1 12-08-2006 01:10 AM
remove blank spaces in a string spandu Shell Programming and Scripting 2 03-02-2006 02:08 AM
Remove blank lines osymad UNIX for Dummies Questions & Answers 4 08-27-2005 06:41 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-11-2008
incredible incredible is offline Forum Advisor  
Registered User
  
 

Join Date: May 2008
Location: s'pore
Posts: 2,063
you can simply remove the blank line by doing
grep . file1 > file2
  #2 (permalink)  
Old 08-24-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Mac line endings are Carriage Returns, so just converting CR to LF should make the file Unix-friendly.

Code:
tr '\r' '\n' <oldfile >newfile
Again, I urge you to search this site if this does not work directly; this question gets asked and answered every week in one form or another.
  #3 (permalink)  
Old 08-24-2008
bakunin bakunin is offline Forum Staff  
Bughunter Extraordinaire
  
 

Join Date: May 2005
Location: In the leftmost byte of /dev/kmem
Posts: 1,628
To remove DOS-style line breaks:

Code:
sed '/^M$//' oldfile > newfile
Notice, that "^M" is a literal line break: in vi press "<CTRL>-<V>", then hit <ENTER> to enter it. You will notice that it is a single character rather than two chars.

To remove lines which contain any number of whitespace (Tabs and or blanks):

Code:
sed '/^[<tab><blank>]*$/d' oldfile > newfile
Enter a literal TAB-char (press <TAB>) and a blank, i just wrote it that way to make it easier to read.

Finally, to find out which unprintable character is bothering you: open the file in vi, enter command mode (press ":") and enter "set list". You will see all the unprintable characters as control codes now (tab characters are represented by "^I" for instance, etc.). Only a blank is now printed as blank char. Enter command mode again and use "set nolist" to switch that off again.

I hope this helps.

bakunin
  #4 (permalink)  
Old 08-24-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Or you can use cat with the -v or -A options (somewhat depending on your version of cat), or look at a hex dump with od or xxd or hexdump
Closed Thread

Bookmarks

Tags
line endings, macintosh, text conversion mac2unix

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:26 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0