The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Unix File operations nivas Shell Programming and Scripting 14 02-11-2008 05:27 AM
Unix file operations(shell script) nivas Shell Programming and Scripting 6 02-07-2008 07:11 AM
command for a series of operations phiber_optik Shell Programming and Scripting 1 12-21-2007 06:57 AM
File operations monks UNIX for Dummies Questions & Answers 2 04-26-2006 08:26 AM
String Operations Rohini Vijay Shell Programming and Scripting 9 04-21-2006 12:32 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-27-2006
chiragmistry21 chiragmistry21 is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 10
Lightbulb File operations

Hi there,

I want some help on scripting regarding file processing.

I have a scenario in which I have 10 files. (file1.txt, file2.txt....) and they are in paricular format.

I want to read these files and append some text lines at the begining of each file and write this updated contents of each file in one paricular file (Combined_files.txt).

so, could you please give a script for this?

Please get back to me if I am not clear in explaining the situation.
Please treat it as urgent!

Thanks in advance!
Chirag
  #2 (permalink)  
Old 03-27-2006
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,131
Quote:
Originally Posted by chiragmistry21
Hi there,

I want some help on scripting regarding file processing.

I have a scenario in which I have 10 files. (file1.txt, file2.txt....) and they are in paricular format.

I want to read these files and append some text lines at the begining of each file and write this updated contents of each file in one paricular file (Combined_files.txt).

so, could you please give a script for this?

Please get back to me if I am not clear in explaining the situation.
Please treat it as urgent!

Thanks in advance!
Chirag

well....... do you have a 7x24 support contract with us?

here's something to start with - feel free to modify.

Code:
#!/bin/ksh

comb='Combined_files.txt'

\rm -rf "${comb}" 2> /dev/null 

for file in *.txt
do
   (
       echo "Here's my header text line1"
       echo "Here's my header text line1"
       cat "${file}"
   ) >> "${comb}"
done


Last edited by vgersh99; 03-27-2006 at 05:08 PM..
  #3 (permalink)  
Old 03-27-2006
chiragmistry21 chiragmistry21 is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 10
Thanks buddy.....

I really appreciate ur help!!

Chirag.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:47 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0