Sponsored Content
Full Discussion: Remove first line of file
Top Forums UNIX for Beginners Questions & Answers Remove first line of file Post 303032826 by jim mcnamara on Sunday 24th of March 2019 08:44:55 PM
Old 03-24-2019
One extra point-- Scrutinizer did a great job of showing possibilities.

Some UNIXES like Linux sed allow for "edit in place"

So for sed - the -i option does that:
Code:
# no option
sed 1d file >newfile
mv newfile file  # back to the starting name

# -i option
sed -i 1d file
# you now have file with the first line removed, no redirection or renzming

 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove every third line from a file

I need to remove every second and every third line from a file. My idea was to do it in two operations. First every third line, then every second line. The problem is that i can't find out how to do it. I tried to look for some sed oneliners, but couldn't find any. Suggestions? (4 Replies)
Discussion started by: bistru
4 Replies

2. Shell Programming and Scripting

Remove header(first line) and trailer(last line) in ANY given file

Hi, I need some help in removing the header (first line) and the trailer (last line) in a give file... The data file actually comes in EBCDIC format and I converted it into ASCII.. Now I need to strip off the first line and the last line.. I think we can use sed to do something like this:... (2 Replies)
Discussion started by: madhunk
2 Replies

3. Shell Programming and Scripting

How to remove last line of the file

hi sir, i need help..how to remove last line of the each file for example i have files a.txt ,b.txt and so on..i wanted to delete last list of each file..the patten not same for each file..any help? thanks in advance (3 Replies)
Discussion started by: mani_um
3 Replies

4. UNIX for Dummies Questions & Answers

remove a line within a file

Hi all, i have a text file similar to belowA1 A2 A3 B1 ... .... *** # first occurance B1 ... .... *** # second occurance B1 ... .... *** # third occurance My desired output is B1 ... .... *** # second occurance B1 ... .... *** # third occurance I want to remove the first line that is after... (3 Replies)
Discussion started by: new2ss
3 Replies

5. Shell Programming and Scripting

Remove a line from a file

Hi ,guys. I have one question: I want to write a script which removes a line with certain string from a file, for example The name of the file is: "passwd", the contents of it is below: ************************* ... brownj2:x:5000: hynesp:x:5001: leeb:x:5002 dioxna:x:5003 ... ... (2 Replies)
Discussion started by: daikeyang
2 Replies

6. Shell Programming and Scripting

Remove line from file

Hi!!! When I use vi editor my file looks like this: aaa2: 123.45^M aaa1: 11.34^M aaa3: aaa3: 15.56^M How to remove only line 3 ??? Thanks!!! (7 Replies)
Discussion started by: tdev457
7 Replies

7. Shell Programming and Scripting

Remove first line of file

Is there an easy way to remove the first line of a file so that the file: aaron benjamin cecilia daniel elliot fernando would become benjamin cecilia daniel elliot fernando (4 Replies)
Discussion started by: locoroco
4 Replies

8. Shell Programming and Scripting

How to remove last line of the file

Hi, unix gurus, I need to remove last line of the file. anybody can help me thanks in advance (7 Replies)
Discussion started by: ken002
7 Replies

9. Shell Programming and Scripting

Remove line from file and read file line by line

I have a file output.txt. File looks like this name1 10 name2 2 name3 5 I get a number n and I need to remove all lines which has number (after name) smaller or equal to n number. After that I need to write lines from file and my output must be like this: Output: 'name1 10' Output: 'name2... (1 Reply)
Discussion started by: kubo12312
1 Replies
diffmk(1)							   User Commands							 diffmk(1)

NAME
diffmk - mark differences between versions of a troff input file SYNOPSIS
diffmk oldfile newfile markedfile DESCRIPTION
diffmk compares two versions of a file and creates a third version that includes "change mark" (.mc) commands for nroff(1) and troff(1). oldfile and newfile are the old and new versions of the file. diffmk generates markedfile, which, contains the text from newfile with troff(1) "change mark" requests (.mc) inserted where newfile differs from oldfile. When markedfile is formatted, changed or inserted text is shown by | at the right margin of each line. The position of deleted text is shown by a single *. USAGE
See largefile(5) for the description of the behavior of diffmk when encountering files greater than or equal to 2 Gbyte ( 2^31 bytes). EXAMPLES
Example 1 An example of the diffmk command. diffmk can also be used in conjunction with the proper troff requests to produce program listings with marked changes. In the following command line: example% diffmk old.c new.c marked.c ; nroff reqs marked.c | pr the file reqs contains the following troff requests: .pl 1 .ll 77 .nf .eo .nh which eliminate page breaks, adjust the line length, set no-fill mode, ignore escape characters, and turn off hyphenation, respectively. If the characters | and * are inappropriate, you might run markedfile through sed(1) to globally change them. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWdoc | +-----------------------------+-----------------------------+ SEE ALSO
diff(1), nroff(1), sed(1), troff(1), attributes(5), largefile(5) BUGS
Aesthetic considerations may dictate manual adjustment of some output. File differences involving only formatting requests may produce undesirable output, that is, replacing .sp by .sp 2 will produce a "change mark" on the preceding or following line of output. SunOS 5.11 14 Sep 1992 diffmk(1)
All times are GMT -4. The time now is 08:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy