I don’t know about sed
, but it can be done with head
:
head -n -2 myfile.txt
More Related Contents:
- Better way to rename files based on multiple patterns
- How do I remove newlines from a text file?
- Insert multiple lines into a file after specified pattern using shell script
- How to check if sed has changed a file
- Replacing Control Character in sed
- When should I wrap quotes around a shell variable?
- How do I test if a variable is a number in Bash?
- sed command with -i option failing on Mac, but works on Linux
- What’s the magic of “-” (a dash) in command-line parameters?
- Pseudo-terminal will not be allocated because stdin is not a terminal
- Is there a “goto” statement in bash?
- How can I generate new variable names on the fly in a shell script?
- How can I delete a newline if it is the last character in a file?
- Bash while read loop extremely slow compared to cat, why?
- Redirect STDERR / STDOUT of a process AFTER it’s been started, using command line?
- Find multiple files and rename them in Linux
- How can I loop over the output of a shell command?
- How to insert a text at the beginning of a file?
- Why does /bin/sh behave differently to /bin/bash even if one points to the other?
- [ :Unexpected operator in shell programming [duplicate]
- ‘find -exec’ a shell function in Linux
- Using the passwd command from within a shell script
- Command to get time in milliseconds
- Bash Script – iterating over output of find
- Syntax with pound and percent sign after shell parameter name [duplicate]
- Randomly shuffling lines in Linux / Bash
- Get ceiling integer from number in linux (BASH)
- How can I trim white space from a variable in awk?
- How do you filter out all unique lines in a file?
- Write a bash shell script that consumes a constant amount of RAM for a user defined time [closed]