Find the answer to your Linux question:
Results 1 to 3 of 3
I typed a comment in a file on my linux server, but i can't remember where i put it. is there a way to find a term, word or directive ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2013
    Posts
    1

    Find a Comment in Ubuntu Linux


    I typed a comment in a file on my linux server, but i can't remember where i put it. is there a way to find a term, word or directive that i've used?

  2. #2
    Linux Enthusiast
    Join Date
    Jan 2005
    Location
    Saint Paul, MN
    Posts
    636
    The command "history' will show the command line commands that you have entered in the shell.

    The command "find" can be used to produce a list of files in a directory tree and that can be piped into "xargs" which is used to run "grep".

    To learn about the commands use man such as:

    man find

  3. #3
    Just Joined!
    Join Date
    Oct 2012
    Posts
    26
    If you know the parent directory the search could be very quick. What I would do, assuming that you cannot remember where the comment is (for example /etc) is:

    Code:
    find /etc -type f | xargs grep -rl "keword-for-the-search" | column -t
    if you do not have any idea where the file may be, change the /etc to /

    Hopefully this helps. Let us know if you find what you're looking for.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •