Sponsored Content
Top Forums Shell Programming and Scripting deleting the lines at the end of the file. Post 302452149 by shashi792 on Thursday 9th of September 2010 11:28:10 AM
Old 09-09-2010
Hammer & Screwdriver deleting the lines at the end of the file.

I have a text file with two coulmn
first column is just used in to show the line number, these line number are not there in the real file.

I want to delete the line 16(in this file) here, even tough there is no data inside it . this empty line is causing me a problem by throwing me garbage value when i input this stream in my c++ program.

Code:
1   0              2.14014e-07
2   13.214      1.00771e-06
3   13.947      3.76252e-05
4   13.958      5.2692e-06
5   13.966     4.87701e-06
6   14.065     3.81149e-06
7   14.076     3.65411e-06
8   14.29       9.82566e-07
9   17.899     6.10872e-07
10  19.757     7.14666e-07
11  200.947    1.78718e-07
12  226.555    1.34066e-07
13  231.43     1.35589e-07
14  231.8       9.41089e-08
15  266.201    1.91486e-07
16

i tried using
Code:
1:  sed -i '/^$/d' file > newfile
2:  sed '/./!d'     file > newfile
3:  sed -e :a -e '/^\n*$/{$d;N;ba' -e '}' file

all these three commands just delete blank line after line 16. but i want my output in the new file to be just

Code:
1   0              2.14014e-07
2   13.214      1.00771e-06
3   13.947      3.76252e-05
4   13.958      5.2692e-06
5   13.966     4.87701e-06
6   14.065     3.81149e-06
7   14.076     3.65411e-06
8   14.29       9.82566e-07
9   17.899     6.10872e-07
10  19.757     7.14666e-07
11  200.947    1.78718e-07
12  226.555    1.34066e-07
13  231.43     1.35589e-07
14  231.8       9.41089e-08
15  266.201    1.91486e-07

and not as the first one

how should i solve this.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Deleting end line spaces for along file

How can i clear all space characteres for a long file at the end of each line? (3 Replies)
Discussion started by: osymad
3 Replies

2. Shell Programming and Scripting

Deleting lines in a file

How do I delete all the lines after the line containing text ***DISCLOSURES*** . I want to delete this line too. Thank you (2 Replies)
Discussion started by: reachsamir
2 Replies

3. UNIX Desktop Questions & Answers

Deleting Junks at the end of each line in a file

Is there any way to delete the Junk Characters(Invalid Characters like ^,',",),(,&,# etc.,) at the end of each record in a file? I want to do this using a single line script. Thanks to all in advance!!! (5 Replies)
Discussion started by: dave_nithis
5 Replies

4. UNIX for Advanced & Expert Users

Deleting end of line $ character in file

Hi, I've got a file where in the middle of the record is a $ end of line character, visible only when I open the file in vi and do :set list. How to I get rid of the character in the middle and keep it at the end. The middle $ character always appears after SW, so that can be used to tag it.... (3 Replies)
Discussion started by: bwrynz1
3 Replies

5. UNIX for Dummies Questions & Answers

Deleting whole lines from a file

I have a file with 65 sets of 35 coordinates, and would like to isolate these coordinates so that I can easily copy the coordinates to another file. The problem is, I've got a 9 line header before each set of coordinates (so each set is 44 lines long). There are a zillion threads out there about... (3 Replies)
Discussion started by: red baron
3 Replies

6. UNIX for Advanced & Expert Users

Deleting lines from a file

How I can delete 100 lines anywhere in a file without opening a file and without renaming the file. (11 Replies)
Discussion started by: Nirgude07
11 Replies

7. Shell Programming and Scripting

deleting lines from file

We have a server that logs transactions to a file. I want to write a script that will delete the first 50 lines of the file daily without renameing the file or moving the file. (8 Replies)
Discussion started by: daveisme
8 Replies

8. UNIX for Dummies Questions & Answers

deleting word from this point to end of file in VI

Hi All i need to delete a recurring word from point "n" till end of the file. there are other words in this file so i cannot use `dG`, can anyone help me out? Kind regards Brian (4 Replies)
Discussion started by: brian112
4 Replies

9. Shell Programming and Scripting

deleting blank lines ONLY at the end of the file

Hi Guys, I have a quetion which was already discussed in the forum, but for some reason all approches suggested fail for me. I have a file which have blank lines at the body of the text as well as at the end. I need to delete ONLY blank lines at the end. Unfortunatly the approach below does not... (5 Replies)
Discussion started by: aoussenko
5 Replies

10. Shell Programming and Scripting

deleting the part of the file(overwrite) using start and end point

here is the contents of bigfile.sql CREATE TABLE `Table11` ( `id` int(11) NOT NULL , `entityName` enum('Lines','EndUsers') COLLATE utf8_unicode_ci NOT NULL, `parentAllianceMigrationProjectId` varchar(255) NOT NULL ) ENGINE=InnoDB AUTO_INCREMENT=2000 DEFAULT CHARSET=utf8... (30 Replies)
Discussion started by: vivek d r
30 Replies
IRSEND(1)							   User Commands							 IRSEND(1)

NAME
irsend - basic LIRC program to send infra-red commands SYNOPSIS
irsend [options] DIRECTIVE REMOTE CODE [CODE...] DESCRIPTION
Asks the lircd daemon to send one or more CIR (Consumer Infra-Red) commands. This is intended for remote control of electronic devices such as TV boxes, HiFi sets, etc. DIRECTIVE can be: SEND_ONCE - send CODE [CODE ...] once SEND_START - start repeating CODE SEND_STOP - stop repeating CODE LIST - list configured remote items SET_TRANSMITTERS - set transmitters NUM [NUM ...] SIMULATE - simulate IR event REMOTE is the name of a remote, as described in the lircd configuration file. CODE is the name of a remote control key of REMOTE, as it appears in the lircd configuration file. NUM is the transmitter number of the hardware device. For the LIST DIRECTIVE, REMOTE and/or CODE can be empty: LIST "" "" - list all configured remote names LIST REMOTE "" - list all codes of REMOTE LIST REMOTE CODE - list only CODE of REMOTE The SIMULATE command only works if it has been explicitly enabled in lircd. -h --help display usage summary -v --version display version -d --device use given lircd socket [/var/run/lirc/lircd] -a --address=host[:port] connect to lircd at this address -# --count=n send command n times EXAMPLES
irsend LIST DenonTuner "" irsend SEND_ONCE DenonTuner PROG-SCAN irsend SEND_ONCE OnkyoAmpli VOL-UP VOL-UP VOL-UP VOL-UP irsend SEND_START OnkyoAmpli VOL-DOWN ; sleep 3 irsend SEND_STOP OnkyoAmpli VOL-DOWN irsend SET_TRANSMITTERS 1 irsend SET_TRANSMITTERS 1 3 4 irsend SIMULATE "0000000000000476 00 OK TECHNISAT_ST3004S" FILES
/etc/lirc/lircd.conf Default lircd configuration file. It should contain all the remotes, their infra-red codes and the corresponding timing and wave- form details. DIAGNOSTICS
If lircd is not running (or /var/run/lirc/lircd lacks write permissions) irsend aborts with the following diagnostics: "irsend: could not connect to socket" "irsend: Connection refused" (or "Permission denied"). SEE ALSO
The documentation for lirc is maintained as html pages. They are located under html/ in the documentation directory. lircd(8), mode2(1), smode2(1), xmode2(1), irrecord(1), irw(1), http://www.lirc.org. irsend 0.9.0-pre1 October 2010 IRSEND(1)
All times are GMT -4. The time now is 08:38 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy