This sed line should do the trick:
sed -i '/^$/d' file.txt
The -i
means it will edit the file in-place.
Related Posts:
- How to sort ps output by process start time?
- How do I grep recursively?
- How do I grep recursively?
- How to get the url of the current svn repo?
- How do I find all files containing specific text on Linux?
- How do I grep recursively?
- How do I use grep to search the current directory for all files having the a string “hello” yet display only .h and .cc files?
- SSH using python script
- How can I exclude directories from grep -R?
- How can I exclude directories from grep -R?
- Argument list too long error for rm, cp, mv commands
- Difference between using “chmod a+x” and “chmod 755”
- How to cat <
> a file containing code? - Extract file basename without path and extension in bash
- Given two directory trees, how can I find out which files differ by content?
- Diff command along with Grep gives “Binary file (standard input) matches”
- How to download a file from server using SSH?
- What is the difference between “#!/usr/bin/env bash” and “#!/usr/bin/bash”?
- Merge / convert multiple PDF files into one PDF
- What does `set -x` do?
- Command to change the default home directory of a user
- Using ls to list directories and their total sizes
- What does “&” at the end of a linux command mean?
- Can’t remove a directory in Unix
- Syntax error near unexpected token ‘then’
- C fopen vs open
- Restarting cron after changing crontab file?
- How do I write stderr to a file while using “tee” with a pipe?
- cd into directory without having permission
- Copying a large directory tree locally? cp or rsync?
- Can I nohup/screen an already-started process?
- Environment variables of a running process on Unix?
- In my /etc/hosts/ file on Linux/OSX, how do I do a wildcard subdomain?
- When does /tmp get cleared?
- How to cd into a directory with this name “-2” (starting with the hyphen)?
- How do I prevent accidental rm -rf /*?
- SSL Certificate Location on UNIX/Linux
- Is it possible to detach a process from its terminal? (Or, “I should have used screen!”) [duplicate]
- What does ‘set -e’ do, and why might it be considered dangerous?
- How do I find the UUID of a filesystem
- Find out symbolic link target via command line
- What useful things can one add to one’s .bashrc? [closed]
- Meaning of directories on Unix and Unix like systems
- How to forcibly close a socket in TIME_WAIT?
- How can I rename a Unix user?
- How to get pid of just started process
- How to display certain lines from a text file in Linux?
- What’s the reverse DNS command line utility?
- Can you have more than one ~/.ssh/config file?
- How to disable everything in crontab -l?
- Amazon Linux: apt-get: command not found
- Where can I find php.ini?
- gzip: stdin: not in gzip format tar: Child returned status 1 tar: Error is not recoverable: exiting now
- How can I recursively find all files in current and subfolders based on wildcard matching?
- Linux: ‘Username’ is not in the sudoers file. This incident will be reported
- “E: Unable to locate package python-pip” on Ubuntu 18.04 [duplicate]
- How to exclude a directory in find . command
- Explaining the ‘find -mtime’ command
- Meaning of exit status 1 returned by linux command
- Creating a new directory in C
- mv: cannot stat error : No such file or directory error
- Linux error while loading shared libraries: cannot open shared object file: No such file or directory
- Pseudo-terminal will not be allocated because stdin is not a terminal
- screen Cannot open your terminal ‘/dev/pts/0’ – please check
- TCP congestion control version: HTCP module vs highspeed module in linux kernel
- How to use regex with find command?
- What is the difference between /etc/rc.local and ~/.bashrc?
- Snort Message – WARNING: No preprocessors configured for policy 0
- Unable to establish SSL connection upon wget on Ubuntu 14.04 LTS
- Getting stty: standard input: Inappropriate ioctl for device when using scp through an ssh tunnel
- How to make rpm auto install dependencies
- How do I install chkconfig on Ubuntu?
- Apache server keeps crashing, “caught SIGTERM, shutting down”
- Using grep and ls -a commands
- List all mounts in Linux
- How to use sed to extract substring
- Wait for user input in C?
- Difference between exec, execvp, execl, execv?
- tar: Error is not recoverable: exiting now
- python-dev installation error: ImportError: No module named apt_pkg
- How to enable Bash in Windows 10 developer preview?
- WordPress sites being filled with random PHP files
- how to properly mount external server directory for wordpress uploads
- Is it a good idea to edit WordPress within Eclipse? [closed]
- What permissions should my website files/folders have on a Linux webserver?
- Can I automatically add a new host to known_hosts?
- How can I run Debian stable but install some packages from testing?
- Meaning of the buffers/cache line in the output of free
- how to disable SSH login with password for some users?
- How can I port forward with iptables?
- Is it possible to make Nginx listen to different ports?
- REJECT vs DROP when using iptables
- Linux command line best practices and tips?
- How to run command as user who has /usr/sbin/nologin as Shell?
- df says disk is full, but it is not
- What is the maximum port number?
- Is there a proper way to clear logs?
- protocol version mismatch — is your shell clean?
- How do I join two named pipes into single input stream in linux
- How should an IT department choose a standard Linux distribution?