LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 10-14-2004, 10:26 AM   #1
redneon
Member
 
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?

Cheers,

Darrell
 
Old 10-14-2004, 11:43 AM   #2
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

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


Reply


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 12:36 AM
Need help with perl/bash script to parse PicBasic file cmfarley19 Programming 13 11-18-2004 05:06 PM
how to edit file from bash commands legend1079 Linux - Newbie 3 03-03-2004 01:59 PM
perl(Cwd) perl(File::Basename) perl(File::Copy) perl(strict)....What are those? Baldorg Linux - Software 1 11-09-2003 08:09 PM
Howto edit a Perl file mickeyboy Red Hat 5 09-30-2003 03:41 PM


All times are GMT -5. The time now is 03:25 PM.

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