Use sponge for this kind of tasks. Its part of moreutils.
Try this command:
grep -v 'seg[0-9]\{1,\}\.[0-9]\{1\}' file_name | sponge file_name
More Related Contents:
- What does 2>&1 mean here?
- In the shell, what does ” 2>&1 ” mean?
- How to store standard error in a variable
- redirect COPY of stdout to log file from within bash script itself
- Bash script – store stderr in a variable [duplicate]
- Send string to stdin
- Can colorized output be captured via shell redirect? [duplicate]
- Piping and Redirection
- What does ” 2>&1 ” mean?
- How to use > in an xargs command?
- How to redirect a program that writes to tty?
- An example of how to use getopts in bash
- Wait for a process to finish
- How do I edit $PATH (.bash_profile) on OS X?
- Running multiple commands with xargs
- Simple logical operators in Bash
- How do I rename the extension for a bunch of files?
- How best to include other scripts?
- What do $? $0 $1 $2 mean in shell script? [duplicate]
- Division in script and floating-point
- Is there a bash command which counts files?
- How can I align the columns of tables in Bash?
- How to determine function name from inside a function
- How to pipe multiple commands into a single command in the shell? (sh, bash, …)
- Loop only iterates once with `ssh` in the body [duplicate]
- Send command to a background process
- Validate date format in a shell script
- How do you return to a sourced bash script?
- How to insert a new line character after a fixed number of characters in a file
- Bash If-statement to check If string is equal to one of several string literals [duplicate]