Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Add line with data to existing file Post 302285609 by avronius on Monday 9th of February 2009 10:17:12 AM
Old 02-09-2009
Here's the code in sh (bourne)
Code:
#!/usr/bin/sh

FILE="/path_to_file/appointments"

COL1=$1
COL2=$2
COL3=$3

if [ -f $FILE ]
then
   echo "$COL1\t$COL2\t$COL3\t" >> $FILE
else
   echo "File \"$FILE\" not found "
   exit 0
fi
exit 0

You'll probably want to:
1. add some error handling for when users don't provide three variables.
2. if you change this script to bash, you'll need to replace \t
3. add some usage message for the users.

It could be simplified to replace "$COL1" with $1, $COL2 with $2, $COL3 with $3 - but you probably want to know what is going on...
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need to add a line of data to already existing file in Unix..

Hello.. I have a text file with 100 lines of data. I need to add 1 line of data to that already existing file at the first line( beginning of the file) , so that the already existing 100 lines will start from 2 nd line.Now the file will have 101 lines of data. Help me on how to add the line... (4 Replies)
Discussion started by: charan81
4 Replies

2. UNIX for Dummies Questions & Answers

add data from command line to end of file

how can I add data from command line to end of file? (3 Replies)
Discussion started by: bryan
3 Replies

3. Shell Programming and Scripting

Need Help for Adding Three new columns in existing file from fatching data from file

not required this time (36 Replies)
Discussion started by: Sandeep_Malik
36 Replies

4. Shell Programming and Scripting

add more data to existing data in a file

Hi all, I need help to add additional data from file2 to existing data in file 1 using awk, sed or perl. the ID in file 1 should match against field $3 in file2 file1 #this is a new game ID HR_1 BASE1 30 BASE2 37 DETAIL No TYPE L @@ ID HR_10 BASE1 6030 BASE2 ... (4 Replies)
Discussion started by: redse171
4 Replies

5. Ubuntu

How to add a data column in existing file

Hi All I need to add a column on my existing data file. I know similar posts are there but none of them were meeting my requirement. My input is 1.20 3.44 4.88 5.11 4.99 3.22 1.89 3.89 2.90 Desired output 1 1.20 3.44 4.88 2 5.11 4.99 3.22 3 1.89 3.89 2.90 I will... (2 Replies)
Discussion started by: mahbub03
2 Replies

6. 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

7. Shell Programming and Scripting

Generate tabular data based on a column value from an existing data file

Hi, I have a data file with : 01/28/2012,1,1,98995 01/28/2012,1,2,7195 01/29/2012,1,1,98995 01/29/2012,1,2,7195 01/30/2012,1,1,98896 01/30/2012,1,2,7083 01/31/2012,1,1,98896 01/31/2012,1,2,7083 02/01/2012,1,1,98896 02/01/2012,1,2,7083 02/02/2012,1,1,98899 02/02/2012,1,2,7083 I... (1 Reply)
Discussion started by: himanish
1 Replies

8. Shell Programming and Scripting

Recoding data in a matrix from an existing file

Hi, I was wondering if someone would be able to help with extrapolating information from a file and filling an existing matrix with that information. I have made a matrix like this (file 1): A B C D 1 2 3 4 I have another file with data like this (file 2): 1 A 1 C 3 C 4 B... (1 Reply)
Discussion started by: hubleo
1 Replies

9. Shell Programming and Scripting

Help with add existing file name as new data column in new output file

Input File 1 cat S1.txt MI0043 2731 miR-1 Input File 2 cat S4.txt MI006 310 CiR-1 MI057 10 CiR-24 MI750 5 CiR-24 Desired Output File 1 cat S1.txt.out MI0043 2731 miR-1 S1.txt Desired Output File 2 cat S4.txt.out MI006 310 CiR-1 S4.txt (3 Replies)
Discussion started by: perl_beginner
3 Replies

10. Shell Programming and Scripting

How to add new line after every data inserted to file?

Hi all, I need help for solve my problem. my problem is like this.. i want to add many word to file. but after I add 1 word, the second word should be in the under of the first word. i have tried but the result is like this word1word2word3 i want the result to be like this word1 word2... (5 Replies)
Discussion started by: weslyarfan
5 Replies
How-To send or update registrations.(3) 			    libeXosip2				   How-To send or update registrations.(3)

NAME
How-To send or update registrations. - eXosip2 offers a flexible API to help you to register one or several identities. Initiate a registration To start a registration, you need to build a default REGISTER request bby providing several mandatory headers osip_message_t *reg = NULL; int id; int i; eXosip_lock (); id = eXosip_register_build_initial_register (identity, registrar, NULL, 1800, &reg); if (id < 0) { eXosip_unlock (); return -1; } osip_message_set_supported (reg, '100rel'); osip_message_set_supported(reg, 'path'); i = eXosip_register_send_register (id, reg); eXosip_unlock (); return i; The returned element of eXosip_register_build_initial_register is the registration identifier that you can use to update your registration. In future events about this registration, you'll see that registration identifier when applicable. Update a registration You just need to reuse the registration identifier: int i; eXosip_lock (); i = eXosip_register_build_register (id, 1800, &reg); if (i < 0) { eXosip_unlock (); return -1; } eXosip_register_send_register (id, reg); eXosip_unlock (); Note: The above code also shows that the stack is sometimes able to build and send a default SIP messages with only one API call Closing the registration A softphone should delete its registration on the SIP server when terminating. To do so, you have to send a REGISTER request with the expires header set to value '0'. The same code as for updating a registration is used with 0 instead of 1800 for the expiration delay. Author Generated automatically by Doxygen for libeXosip2 from the source code. Version 3.1.0 Sun Jun 24 2012 How-To send or update registrations.(3)
All times are GMT -4. The time now is 10:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy