Appending error


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Appending error
# 1  
Old 03-05-2010
Appending error

Hi All,

I just want to append the value in variable at the end of the file.

Code:
var=1234
sed -e "$a $var" file1 > file 2.

But I get this error
Code:
sed: -e expression #1, char 4: unknown command: `1'

Kindly let m know how can I do that...

Last edited by Scott; 03-05-2010 at 02:11 AM.. Reason: Please use code tags
# 2  
Old 03-05-2010
If you want to append the value of variable,you can use the echo command.I don't know why you're using?Whether you want the values of variables a and var to file.

Then try this,

Code:
echo "$a $var" > file

# 3  
Old 03-05-2010
I used this because I wanted to append the value of var at the end of the file. it reads data from file1 and appends var at the end and save it in file 2

var=1234
sed -e "$a $var" file1 > file2
# 4  
Old 03-05-2010
'>' will simple rewrite . use '>>' to append.

Code:
echo "$var1 $var2 $var3" >> file

# 5  
Old 03-05-2010
Try this,

Code:
sed  -e "${a} ${var}" file1 > file2

# 6  
Old 03-05-2010
No NILA it didn work

If I use this sed -e '$a $var' file1 > file2 it does work but it dosnt read var as a variable rather it reads it as text and place text "$var" at the end of the file.

---------- Post updated at 05:21 AM ---------- Previous update was at 04:50 AM ----------

Thnxx karthigayan

echo "$var1 $var2 $var3" >> file places data right where I wanted it to be
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Appending ErrorCodes to the corresponding error record

Hi, Here i'm using a awk inside bash script to validate the datafile by referring to the configuration file(schema file). Here the validation check is done for datatype, field length and null values. Once the validation is done on data file the error records are moved to the bad file. So... (22 Replies)
Discussion started by: shree11
22 Replies

2. Shell Programming and Scripting

Appending error messages from log file next to the corresponding error record

Hi Everyone, I have an issue and trying to get a solution but was not succesful yet. Any help is greatly appreciated. I am using ksh to inoke sql loader to load data from txt file into two oracle tables based on the condition written in the control file. If an error occurs while loading into... (8 Replies)
Discussion started by: vpv0002
8 Replies

3. Shell Programming and Scripting

Appending value to variable

I have a Query! by using command cat >> file1 we can append data's to a already existing file, Similarly is it possible to append a data to a variable. Thanks in Advance!! (2 Replies)
Discussion started by: gwgreen1
2 Replies

4. Shell Programming and Scripting

Error while appending records to a file

Hi, I have a sample file which contains records. Input File : 1 user1 username1\password@database-name 2 user2 username2\password@database-name 3 user3 username1\password@database-name I should search for a 'username1\' in those records. If 'username1\' is found in those records, that record... (7 Replies)
Discussion started by: siri_886
7 Replies

5. Shell Programming and Scripting

appending two strings

Hi, I have a small doubt. Here is the code snippet for which the output that I'm getting are a bit surprising. testing.sh #!/bin/sh arg_1=$1 echo "arg passed by user is:${arg_1}" mapping=`grep ${arg_1}= testing.conf | awk -F"=" '{print $2}'` echo "mapping is $mapping"... (4 Replies)
Discussion started by: badrimohanty
4 Replies

6. Shell Programming and Scripting

appending strings

Hi , while trying to append two strings, it is not properly coming. my code will be like this str1=_TrackingEAR srt2=1.0.0-20080523.155438-12 i am trying to build str3=$str1$str2.tgz but it is appending the last value ot the begingin of the string , but i expect to the end of the... (1 Reply)
Discussion started by: scorpio
1 Replies

7. AIX

pax error on appending data to LTO3

I have problem when I use the command "pax -awvf /dev/rmt0 ./data1" in AIX 5.3.0.0. The command with parameter -a allow me to append the tape but when I try to retrieve the data that I append, it will show me error. I would like to know if anyone have the same problem and any solution found? Tq. (0 Replies)
Discussion started by: kwliew999
0 Replies

8. Shell Programming and Scripting

appending

hi, a1.txt ------ xyz zxc xya xdf a2.txt ------ a1 a2 b1 b2 cat a1.txt >> a2.txt -->its appending at the end (6 Replies)
Discussion started by: mohan705
6 Replies

9. UNIX for Dummies Questions & Answers

using diff and appending

Hi, I have two files in an html folder I would like to compare using diff. However I would like to append those files to a text file that is two folders up in my directory. Every time I try to do this I lose my information. What is happening and what should I do? (3 Replies)
Discussion started by: muclc7
3 Replies

10. Shell Programming and Scripting

appending

i've been fiddling around with append and I know how to append a word into a file, but how would you go about appending a word to a filename? (5 Replies)
Discussion started by: codewarrior7
5 Replies
Login or Register to Ask a Question