You can use xargs
:
grep 'pattern' input | xargs -I% cp "%" "%.bac"
More Related Contents:
- Get exit code of a background process
- Is there a way to change the environment variables of another process in Unix?
- What’s the magic of “-” (a dash) in command-line parameters?
- Environment variable substitution in sed
- What does “&” at the end of a linux command mean?
- Aborting a shell script if any command returns a non-zero value
- Better way to rename files based on multiple patterns
- Linux: copy and create destination dir if it does not exist
- What is the difference between using `sh` and `source`?
- Setting environment variables in Linux using Bash
- What is the difference between “#!/usr/bin/env bash” and “#!/usr/bin/bash”?
- Does “argument list too long” restriction apply to shell builtins?
- Given two directory trees, how can I find out which files differ by content? [closed]
- How to sort a file in-place?
- Using the passwd command from within a shell script
- Is it OK to use the same input file as output of a piped command?
- Finding contents of one file in another file
- When to wrap quotes around a shell variable?
- How do you normalize a file path in Bash?
- How to compare two DateTime strings and return difference in hours? (bash shell)
- Linux/Unix command to determine if process is running?
- How can I copy the output of a command directly into my clipboard?
- Using grep and sed to find and replace a string
- Running shell script in parallel
- Difference between shell and environment variables
- What’s the point of eval/bash -c as opposed to just evaluating a variable?
- Syntax error near unexpected token ‘then’
- Why doesn’t “sort file1 > file1” work?
- Need to remove the count from the output when using “uniq -c” command
- How do you run a script on login in *nix?