![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| copy files from one location to similar location | pharos467 | UNIX for Advanced & Expert Users | 1 | 09-21-2008 01:21 PM |
| Need Help for Adding Three new columns in existing file from fatching data from file | Sandeep_Malik | Shell Programming and Scripting | 36 | 09-17-2008 06:12 PM |
| adding data behind a line | cherrywinter | Shell Programming and Scripting | 1 | 08-01-2008 06:55 PM |
| What is the file location? | Chanakya.m | Shell Programming and Scripting | 5 | 07-17-2006 01:42 AM |
| Adding files of numerical data | Boucho | High Level Programming | 17 | 02-07-2006 04:29 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
adding the data at a specified location in a file....
Hi all,
I m new to shell programming..Can anyone please guide me how to insert data at a specified location in the file.. I have a configuration file..I want to add data to it through script..I am able to do it...I get that data written at end of my configuration file..I want data to be placed at a specified location... As,I have a header [mydata] in my configuration file..I want to place the data here... Is it possible to do that... Example: My configuration file: [global] hello aaa bbbb [share] gghg hnnmm bbb [mydata] gggg [printing] cvbvbb vbvbb Now,I want my data to be entered after header [mydata], not at the end of Configuration file... Thanking you... |
|
||||
|
Hi,
Thanks so much..This has helped me to understand the concept... Actually,This is my script which inserts the data into the configuration file.. #!/bin/bash CF="/etc/samba/smb-test.conf" //Configuration file ..................... ............... insert_mod() { //Function to insert data into config file NCF="$CF.$$" [ ! -f $CF ] && touch $CF || : V="$1" grep -v -E "^$V=" $CF > $NCF mv -f $NCF $CF eval echo "$V\"'\${$V}'\"">> $CF } hello=yes insert_mod hello //Function called with argument else illegal fi ............... SO,HOW CAN I USE sed COMMAND HERE.... Thanking you in advance... |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|