Create a file using a existed file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Create a file using a existed file
# 1  
Old 02-15-2012
Create a file using a existed file

Hello everyone,

My problem is suppose I have one file name dipanjan.conf and the format of this file is as follows-
Name : Ddd Rrr Ooo
Email : abc@pqr.com
Mobile No : +8801911000000

Now, I want to create a new file using this one by shell script giving parameter (1)name, (2)email & (3)mobile no.
Actually I try a lot, but not able to solve this one. Can anybody please help me?
# 2  
Old 02-15-2012
Quote:
Originally Posted by sreejond
Now, I want to create a new file using this one by shell script giving parameter (1)name, (2)email & (3)mobile no.
Actually I try a lot, but not able to solve this one. Can anybody please help me?
you can read the file line by line and store the parts behind ":" into 3 different arrays.
after that iterating through these arrays and writing into a new created file.
# 3  
Old 02-15-2012
Please provide your input file you have, the output you expect, as well as the code you have done so far so people may then be able to help.
# 4  
Old 02-15-2012
If names are unique you may try this:
Code:
grep -A2 "Name : Ddd Rrr Ooo" inputfile >> newfile

# 5  
Old 02-15-2012
If it is a configuration file why don't you just

Code:
Name="Ddd Rrr Ooo"
Email="abc@pqr.com"
Mobile_No="+8801911000000"

and then load these variables in your environment :

Code:
. ./dipanjan.conf

???

I mean, instead of using a wrongly formatted configuration file that you then have to parse, just use a correclty formatted one that you can directly load.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Create a text file and a pdf file from Linux command results.

Hello. The task : Using multiple commands like : gdisk -l $SOME_DISK >> $SOME_FILEI generate some text file. For readiness I must insert page break. When the program is finished I want to convert the final text file to a pdf file. When finished, I got two files : One text file and One pdf... (1 Reply)
Discussion started by: jcdole
1 Replies

2. Shell Programming and Scripting

Bash to search file based off user input then create new file

In the below bash a file is downloaded when the program is opened and then that file is searched based on user input and the result is written to a new file. For example, the bash is opened and the download.txt is downloaded, the user then enters the id (NA04520). The id is used to search... (5 Replies)
Discussion started by: cmccabe
5 Replies

3. Shell Programming and Scripting

Is it possible to create 10GB file in Linux and transferring the file to other remote server

Hi folks, Is it possible to create 10GB file in linux and transferring the file to other remote server? Regards, J (3 Replies)
Discussion started by: scriptscript
3 Replies

4. Shell Programming and Scripting

create txt file form data file and add some line on it

Hi Guys, I have file A.txt File A Data AK1521 AK2536 AK3164 I want create text file of all data above and write some data on each file. want Output on below folder /home/kka/out AK1521.txt Hi Welocme (3 Replies)
Discussion started by: asavaliya
3 Replies

5. Shell Programming and Scripting

Create shell script to extract unique information from one file to a new file.

Hi to all, I got this content/pattern from file http.log.20110808.gz mail1 httpd: Account Notice: close igchung@abc.com 2011/8/7 7:37:36 0:00:03 0 0 1 mail1 httpd: Account Information: login sastria9@abc.com proxy sid=gFp4DLm5HnU mail1 httpd: Account Notice: close sastria9@abc.com... (16 Replies)
Discussion started by: Mr_47
16 Replies

6. Shell Programming and Scripting

Newbie.. Find if a file exists and open, if not create the desired file..

Hey all, I'm brand new to script writing, I'm wanting to make a script that will ask for a file and then retrieve that file if it exists, and if it doesn't exist, create the file with the desired name, and I'm completely stuck.. so far.. #! bin/bash echo "Enter desired file" read "$file" if ... (5 Replies)
Discussion started by: Byrang
5 Replies

7. Shell Programming and Scripting

Read a file and search a value in another file create third file using AWK

Hi, I have two files with the format shown below. I need to read first field(value before comma) from file 1 and search for a record in file 2 that has the same value in the field "KEY=" and write the complete record of file 2 with corresponding field 2 of the first file in to result file. ... (11 Replies)
Discussion started by: King Kalyan
11 Replies

8. Shell Programming and Scripting

checking file whether existed in another server or not

need a shell script in unix to check whether a file is existed in dir after connecting using ftp (2 Replies)
Discussion started by: KiranKumarKarre
2 Replies

9. Shell Programming and Scripting

checking file whether existed in another server or not

Hi, i am in 272.22.22.32 server, and i want to check whether a file test.txt file exists in different server like 372.23.23.23 using shell script. can any one help me out. (1 Reply)
Discussion started by: KiranKumarKarre
1 Replies
Login or Register to Ask a Question