LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 06-09-2007, 03:42 AM   #1
ovince
Member
 
Registered: Mar 2007
Posts: 77

Rep: Reputation: 15
header


hi,

I wrote a simple bash script:

putHeader(){
for fl in `find -name "$1"`; do
echo $fl;
tmpNm=$(basename $fl).tmp;
awk -v hd=$2 'BEGIN{print "hd"}' $fl > $tmpNm
#sed -e '1i \ $2' $fl > $tmpNm
rm $fl
mv $tmpNm $fl
done
}

I would like to put header into specified files like:

putHeader "*.dat" "energy errors"

Nither, awk not sed does not work. Could someone tell me why?
 
Old 06-09-2007, 12:03 PM   #2
indienick
Senior Member
 
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853

Rep: Reputation: 65
Try surrounding the awk and sed lines with backticks (`).
 
  


Reply



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
C header files mystic-d Slackware 9 08-21-2006 01:49 PM
header file saadiaomar Programming 4 03-23-2006 04:18 PM
2.6.15 Header? b0rgri0t Slackware 23 01-22-2006 12:25 PM
Conectiva Header psycho_death Linux - Hardware 1 07-20-2004 12:39 AM
c header files in linux in place of header files in windows? harun_acs Programming 1 03-17-2004 02:24 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration