LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-19-2008, 11:40 PM   #1
an_sush
Member
 
Registered: Nov 2008
Posts: 46

Rep: Reputation: 15
add String in awk


How can i add strings in awk?
the normal '+' operator does a aritmetic addition and not string addition
 
Old 11-20-2008, 11:42 AM   #2
PAix
Member
 
Registered: Jul 2007
Location: United Kingdom, W Mids
Distribution: SUSE 11.0 as of Nov 2008
Posts: 195

Rep: Reputation: 40
Often you will require to put brackets around some statements to ensure that they are reevaluated, particularly arguments in printf statements.

Answer to your direct question:
If a variable is not initialized, awk uses default values: -- numeric = 0 (zero) : -- string = " " (null string)

Code:
print(1 2) = 3
print(1 2 "") = 12
Normally: to force numeric evaluation add 0, to force string evaluation add ""
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
awk: Using split to divide string to array. How do I find out the number of elements? vxc69 Programming 9 02-09-2008 01:49 PM
Excluding a string in awk when printing szahri Programming 2 03-22-2007 03:00 AM
awk escape character for colon in string quadmore Programming 2 02-27-2007 05:56 PM
[Bash] Concatenate string using awk senorsnor Programming 7 05-05-2005 01:38 AM
string concatenation in AWK xanthium Programming 1 04-22-2002 05:41 AM


All times are GMT -5. The time now is 01:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration