Open a file using vim from the output of pipe command
sed, vim
Solution
The right command would be like this:
vim "$(sed -n 4p abc.txt)"
The difference is that this passes the output of sed as the first argument to vim. As a result, Vim will open that file.
In the command you've typed, the output of sed is piped to the standard input of vim. Since you're passing '-' as the argument to Vim, it assumes that the text to edit is what is coming through the standard input. This text is the filename, but not the contents of the file.
Problem
I have a list of files in a text file `abc.txt` . I have to read the nth line from the file and open the file using vim . I have done this but the file at nth line doesn't open :- `sed -n 4p abc.txt | vim -` Trying to get 4th line from `abc.txt` and opening it using vim .But the output I get is content of file at that particular line number :-