Sponsored Content
Top Forums Shell Programming and Scripting UNIX command to count blank lines in a file in DOS format Post 302745217 by RudiC on Monday 17th of December 2012 03:21:03 AM
Old 12-17-2012
You can adapt your own command:
Code:
$ grep ^^M$ file|wc -l
2

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to count lines - ignoring blank lines and commented lines

What is the command to count lines in a files, but ignore blank lines and commented lines? I have a file with 4 sections in it, and I want each section to be counted, not including the blank lines and comments... and then totalled at the end. Here is an example of what I would like my... (6 Replies)
Discussion started by: kthatch
6 Replies

2. Shell Programming and Scripting

Unix help to find blank lines in a file and print numbers on that line

Hi, I would like to know how to solve one of my problems using expert unix commands. I have a file with occasional blank lines; for example; dertu frthu fghtu frtty frtgy frgtui frgtu ghrye frhutp frjuf I need to edit the file so that the file looks like this; (10 Replies)
Discussion started by: Lucky Ali
10 Replies

3. Shell Programming and Scripting

Command for unix to dos conversion

Dear All Could you please advice how do we convert a unix file to dos I know one command,ux2dos, which somehow does not work to give desired output Inputs on this is appreciated Thanks, Suresh (3 Replies)
Discussion started by: sureshg_sampat
3 Replies

4. Shell Programming and Scripting

Count uncommented, blank and source lines in perl

Hi friends, I am working on a perl script to count the commented lines, blank lines and source lines separately. Let me know if you have one. For example i have a file containing the lines: /** * SOURCE CODE */ public class SessionConstants { /** * Code for Session created */... (4 Replies)
Discussion started by: nmattam
4 Replies

5. UNIX for Dummies Questions & Answers

converting scripts from dos 2 unix format

Hi, I am new to shell scripting and exploring it , I have developed few sample shell script but I have developed them on windows xp notepad and then saving them on folder and then testing them on cywgin and running perfectly...but these scripts are in dos format and I want to convert them in unix... (1 Reply)
Discussion started by: rahul125
1 Replies

6. Shell Programming and Scripting

Cat Command on File not printing "Blank" Lines?

Hello All, I have a bash script and in it at some point I call an Expect Script that does some stuff and saves its output in a ".txt" file. Example "/path/to/my/file/Expect_Output.txt" file: notice the 2nd line is empty in the file... Data for Host-1 (192.168.1.110) Checking the... (2 Replies)
Discussion started by: mrm5102
2 Replies

7. Shell Programming and Scripting

Script to check dos format in a file

Hi All, I am trying to check if the file is in dos format using simple grep command but the problem is lines inside the file with have special characters in between and in some lines end of the line will have the '^M' character. I tried the below command in simple line(without special... (7 Replies)
Discussion started by: Optimus81
7 Replies

8. UNIX for Advanced & Expert Users

Delete blank spaces and blank lines in a file

Hi Gurus, Somebody can say me how to delete blank spaces and blank lines in a file unix, please. Thank you for advanced. (10 Replies)
Discussion started by: systemoper
10 Replies

9. Shell Programming and Scripting

To check Blank Lines, Blank Records and Junk Characters in a File

Hi All Need Help I have a file with the below format (ABC.TXT) : ®¿¿ABCDHEJJSJJ|XCBJSKK01|M|7348974982790 HDFLJDKJSKJ|KJALKSD02|M|7378439274898 KJHSAJKHHJJ|LJDSAJKK03|F|9898982039999 (cont......) I need to write a script where it will check for : blank lines (between rows,before... (6 Replies)
Discussion started by: chatwithsaurav
6 Replies

10. Shell Programming and Scripting

Line count of a dos file in kshell

dos file in unix environment , now want to get the line count of the file . Is it possible???/ (1 Reply)
Discussion started by: lalitpct
1 Replies
mread(1)						      General Commands Manual							  mread(1)

NAME
mread - mtools utility to perform a low level read (copy) of a DOS file to UNIX SYNOPSIS
mread [-tnm] msdosfile unixfile mread [-tnm] msdosfile [msdosfiles...] unixdirectory OPTIONS
Preserves the file modification time. Specifies that a warning is not issued when an existing file is specified as the target file. If this option is not specified, the mread command verifies whether or not to overwrite an existing file. Specifies a text file transfer. Line terminators are converted to the appropriate format. DESCRIPTION
The mread command copies the specified DOS file to the named UNIX file, or copies multiple DOS files to the named UNIX directory. DOS subdirectory names that contain the '/' or '' separator are supported. If you use the '' separator or wildcards, you must enclose file names in quotes to protect them from the shell. The mcd command can be used to establish the device and the current working directory (relative to DOS), otherwise the default is A:. RESTRICTIONS
Unlike DOS convention, the destination directory may not be omitted. EXIT STATUS
The following exit values are returned: Success. Failure. ENVIRONMENT VARIABLES
The following environment variables affect the execution of mread: If set, this variable names the file that contains the name of the cur- rent mtools working directory as established by the mcd command. If this variable is not set, the file $HOME/.mcwd is used. FILES
Contains the name of the current mtools working directory as established by the mcd command. If this file does not exist, the default mtools working directory is A:. Executable file SEE ALSO
Commands: dos2unix(1), mcd(1), mcopy(1), mdiskcopy(1), mtools(1), mtype(1), mwrite(1), unix2dos(1) mread(1)
All times are GMT -4. The time now is 08:54 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy