Announcement

Collapse
No announcement yet.

How to add a line to files found with find

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to add a line to files found with find

    I am trying to develop a command to find all .bashrc files in the /home directory on the system (dumping errors to the bit bucket), and add a line to each to change the ps1 prompt to > .

    This is my silly attempt so far :

    find /home .bashrc 2>/dev/null

    which is just finding the files without error messages. But to add ps1 = > to each line all in one command, I need a lil help. Thanks guys.

    #2
    Re: How to add a line to files found with find

    I don't think I get the gist of what you are wanting to do. If all you want to do is find .baschrc files in your home directory, you can open a console (which will open in your home directory) and type:
    Code:
    ls -l .bashrc*
    Windows no longer obstructs my view.
    Using Kubuntu Linux since March 23, 2007.
    "It is a capital mistake to theorize before one has data." - Sherlock Holmes

    Comment


      #3
      Re: How to add a line to files found with find

      for i in `command to generate list of files`; do somecommand; othercommand; done

      "echo foo >> bar" will append the string "foo" to the end of file bar.

      Hope this helps!

      Comment

      Working...
      X