Share your knowledge at the LQ Wiki.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 10-14-2004, 11:26 AM   #1
Registered: Aug 2003
Posts: 103

Rep: Reputation: 15
Perl or Bash Mass File Edit

I'm wanting a program which will add a single line to the beginning of every .html recursively in a directory (and every directory below it). I'm assuming the best way to do this would be to use bash or perl but I'm not sure where to start. Can someone point me in the right direction?


Old 10-14-2004, 12:43 PM   #2
jim mcnamara
Registered: May 2002
Posts: 964

Rep: Reputation: 36
for file in `find  /path/to/ -name \*.html -print`
       awk ' BEGIN { print "this is my new line" }
               { print $0 } ' $file > tmp.tmp
       mv tmp.tmp $file
try this on JUNK files first, then proceed from there


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
BASH USAGE: mass files rename sirpelidor Linux - General 8 09-20-2005 01:36 AM
Need help with perl/bash script to parse PicBasic file cmfarley19 Programming 13 11-18-2004 06:06 PM
how to edit file from bash commands legend1079 Linux - Newbie 3 03-03-2004 02:59 PM
perl(Cwd) perl(File::Basename) perl(File::Copy) perl(strict)....What are those? Baldorg Linux - Software 1 11-09-2003 09:09 PM
Howto edit a Perl file mickeyboy Red Hat 5 09-30-2003 04:41 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:19 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration