Runaway String Problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Runaway String Problem
# 1  
Old 01-19-2010
Runaway String Problem

Code:
Database.txt
John:30:40

Code:
echo -n "New Title Please :"
read NewTitle
awk -F":"  'OFS = ":"{ $1 = "'$NewTitle'" ; print $0 } ' Database.txt> Database2.txt
mv Database2.txt Database.txt

what this does, is that when i input something into $NewTitle, it will update $1 which is "John" into the input which i key in earlier.

the problem i am having is that when i input a single line like "mark" into $NewTitle ,the thing is updated properly , but when i input a string such as "mark twain" , i will receive an error saying

Code:
awk: line 1: runaway string constant "ffe ...

what does this mean and how do i solve it?
# 2  
Old 01-19-2010
You can try setting an awk variable using the -v option and then using that variable instead of the shell variable inside the awk command. This approach worked for me:
Code:
read new_title
echo $new_title
awk -F":" -v var="$new_title" 'OFS = ":"{ $1 = var ; print $0 }' testfile


Last edited by Scott; 01-19-2010 at 04:09 PM.. Reason: Added code tags
# 3  
Old 01-19-2010
Try fliiping around the quotes and escaping the double quotes:
Code:
$1 = '"\"$NewTitle\""'


Last edited by Scrutinizer; 01-19-2010 at 03:16 PM..
# 4  
Old 01-19-2010
thanks for the help guys, i solved it.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to solve awk: line 1: runaway string constant error?

Hi All ! I am just trying to print bash variable in awk statement as string here is my script n=1 for file in `ls *.tk |sort -t"-" -k2n,2`; do ak=`(awk 'FNR=='$n'{print $0}' res.dat)` awk '{print "'$ak'",$0}' OFS="\t" $file n=$((n+1)) unset ak doneI am getting following error awk:... (7 Replies)
Discussion started by: Akshay Hegde
7 Replies

2. AIX

Runaway Processes (I think)

Folks I suck a lot of things and performance issue is one of them. After upgrading from 5300-06-03 to 5300-12-04 we started seeing an issue with some runaway processes. It varies as some of these processes have a TTY accociated with them and some do not. If you could give me any idea of what... (4 Replies)
Discussion started by: juredd1
4 Replies

3. Shell Programming and Scripting

Parsing a long string string problem for procmail

Hi everyone, I am working on fetchmail + procmail to filter mails and I am having problem with parsing a long line in the body of the email. Could anyone help me construct a reg exp for this string below. It needs to match exactly as this string. GetRyt... (4 Replies)
Discussion started by: cwiggler
4 Replies

4. Shell Programming and Scripting

Problem in comparing 2 files string by string

Hi Champs, I am a newbie to unix world, and I am trying to built a script which seems to be far tough to be done alone by me..... " I am having a raw csv file which contains around 50 fields..." From that file I have to grep 2 fields "A" and "B"....field "A" is to be aligned vertically... (11 Replies)
Discussion started by: jitendra.pat04
11 Replies

5. UNIX for Dummies Questions & Answers

Runaway process

Hello all, My hosting provider has contacted me in order to notify about a runaway process issue. Here it is: They have given me a list of those processes but I can neither analyze nor understand what I should do. DATE Fri Nov 21 21:32:29 GMT 2008 SINFO hostname:... (2 Replies)
Discussion started by: elwoodblues47
2 Replies

6. Programming

Runaway SIGALRM signal handler

I have written a program to demonstrate a problem I have encountered when using BSD style asynchronous input using the O_ASYNC flag in conjunction with a real time interval timer sending regular SIGALRM signals to the program. The SIGIO handler obeys all safe practices, using only an atomic update... (8 Replies)
Discussion started by: stewartw
8 Replies

7. UNIX for Dummies Questions & Answers

problem with if -z string

someone please help me out here. i am not a newbie. i just haven't posted on this board in years. i'm talking at least two and a half years. My last user name was TRUEST. i couldn't log into this name because i forgot my password and my aol email address has long been deleted. anyway, i'm... (1 Reply)
Discussion started by: Terrible
1 Replies

8. Shell Programming and Scripting

sed problem - replacement string should be same length as matching string.

Hi guys, I hope you can help me with my problem. I have a text file that contains lines like this: 78 ANGELO -809.05 79 ANGELO2 -5,000.06 I need to find all occurences of amounts that are negative and replace them with x's 78 ANGELO xxxxxxx 79... (4 Replies)
Discussion started by: amangeles
4 Replies

9. UNIX for Dummies Questions & Answers

Runaway processes killed (Really need help)

I got about more than 300 emails from root with the subject "Runaway processes killed" saying that "13146 12737 97.7 6 bash" . So what should I do? Any help would be appreciate (2 Replies)
Discussion started by: Micz
2 Replies

10. UNIX for Advanced & Expert Users

Runaway process. Opinions needed

not too long ago, i wrote a very short script that will bring up 4 customized xterms. The script went completely abnormal simply because of an error I had made in a while loop. This script took control of the system and rendered everything useless. The system admin team which i was part of... (4 Replies)
Discussion started by: TRUEST
4 Replies
Login or Register to Ask a Question