Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6879047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:47:55+00:00 2026-05-27T04:47:55+00:00

I often find find myself doing a workflow like this: $ find . |grep

  • 0

I often find find myself doing a workflow like this:

$ find . |grep somefile
./tmp/somefile.xml
./test/another-somefile.txt

(review output)

$ vim ./tmp/somefile.xml

Now, it would be neat if there was some convenient way of using the output of the find command and feed it to vim.

The best I’ve come up with is:

$ nth () { sed -n $1p; }
$ find . |grep somefile
./tmp/somefile.xml
./test/another-somefile.txt

(review output)

$ vim `!!|nth 2`

I was wondering if there are other, maybe prettier, ways of accomplishing the same thing?

To clarify, I want a convenient way of grabbing the nth line from a previously run command to quickly open that file for editing in vim, without having to cut & paste the filename with the mouse or tab-complete my way through the file path.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:47:55+00:00Added an answer on May 27, 2026 at 4:47 am

    way 1: don’t pass exact file to vim, but the whole output. choose the file in vim

    currently you are working in two steps:

    1 – launch the find/grep… cmd

    2 – vim !!….

    if you are sure that you want to use vim to open one (or more) file(s) from the find result. you may try:

    find. (with grep if you like)  |vim -
    

    then you have the whole output in vim, now you can use vim magic to move cursor to the file you want to edit, then press gf. (I do this sometimes)

    way 2: refine your regex in your find (or grep), to get the single file, that you want to edit.

    this is not a hard thing at all. then you can just vim !!.

    your nth() is nice. however imagine there are 30 lines in output, and your file sits in the line# 16. how do you count it? sure you can add |nl at the end, then you cannot directly use !! any longer..

    just my 2 cents

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I often find myself doing quick checks like this: if (!eregi('.php', $fileName)) { $filename
I find myself adding debugging print statements quite often -- stuff like this: print(a_variable_name:
Ok, I find myself doing this often. I'll attach ids to my tables and
I often find myself writing class constructors like this: class foo: def __init__(self, arg1,
Doing component-based development, I find myself doing this fairly often: public class SomeClass {
While using Vim (at home and at work), I often find myself doing similar
One of the things I find myself doing often is passing string literals as
I often find myself writing a property that is evaluated lazily. Something like: if
I often find myself doing inefficient loops as such: def __add__(self, other): dimensions =
Often I find myself doing the following: print Input text: input = gets.strip Is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.