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
Need to serach if a new line character exists on the last line in a file sunilbm78 UNIX for Dummies Questions & Answers 10 02-29-2008 02:15 PM
how to add new line character ravi.sadani19 Shell Programming and Scripting 3 11-23-2007 03:26 AM
delete a line based on first character of the line borncrazy UNIX for Dummies Questions & Answers 2 12-06-2005 03:27 PM
stripping last character from end of each line hcclnoodles UNIX for Dummies Questions & Answers 6 11-21-2005 08:35 PM
Line-drawing character! zecoj High Level Programming 5 03-10-2002 11:38 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-19-2004
zomboo zomboo is offline
Registered User
  
 

Join Date: Aug 2004
Posts: 6
end of the line character

How do i determine what the end of the line character is in a text file. for eg. is it \n or \f or \t etc..

Is there a unix command for this?
  #2 (permalink)  
Old 11-19-2004
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
  
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
I'd do something like
Code:
head -1 myfile | od -ta
For a DOS file, you get
Code:
0000000   m   y   l   i   n   e   cr  nl
(cr = \r, nl = \n)

For a UNIX file, you get
Code:
0000000   m   y   l   i   n   e   nl
Cheers
ZB
  #3 (permalink)  
Old 11-21-2004
AbEnd AbEnd is offline
Registered User
  
 

Join Date: Sep 2003
Location: Canada
Posts: 56
file(1) will tell you, too.
  #4 (permalink)  
Old 12-30-2004
lesstjm lesstjm is offline
Registered User
  
 

Join Date: Nov 2001
Posts: 59
thanks

thank you
  #5 (permalink)  
Old 12-30-2004
videsh77 videsh77 is offline
Registered User
  
 

Join Date: Aug 2004
Posts: 144
AbEnd,
I didnt get it how you give your command on the file?
  #6 (permalink)  
Old 12-30-2004
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
  
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
Quote:
Originally posted by videsh77
I didnt get it how you give your command on the file?
To quote from a manual page for a version of file included with recent Linux

Quote:
In addition, file will attempt to determine other characteristics of text-type files. If the lines of a file are terminated by CR, CRLF, or NEL, instead of the Unix-standard LF, this will be reported.
At the command prompt....

For a standard UNIX file (LF (i.e. \n) terminators)
$ file my_file
my_file: ASCII text

For a DOS file ( \r\n terminators )
$ file my_file
my_file: ASCII text, with CRLF line terminators

Cheers
ZB
Closed Thread

Bookmarks

Tags
linux

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 11:22 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