![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
awk question
Is there a string concatenation function such as the 'C' strcat in awk? If not, how could I accomplish this (using awk)?
|
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Re: awk question
Quote:
according to this site: http://www.cs.uu.nl/docs/vakken/st/nawk/nawk_60.html There is only one string operation: concatenation. It does not have a specific operator to represent it. Instead, concatenation is performed by writing expressions next to one another, with no operator. For example: |
|
#3
|
|||
|
|||
|
There is no separate strcat function in awk. String
concatenation is build into the language. Here is a simple awk script which demonstrates string concatenation in awk. BEGIN { str="strcat" for (i =0; i < 3; i++) str = str " demo" i print length(str), str } Hope this helps - Finnbarr |
|
#4
|
||||
|
||||
|
Code:
echo $PARENT_PATH | awk ' {
arraySize = split($0, parentPath, "/");
delete parentPath[arraySize];
for (i in parentPath ) {
w = w parentPath[i];
}
print w
}'
r = / w = w r but awk doesnt like it! thanks for the help. Last edited by google; 12-17-2003 at 04:17 PM. |
|
#5
|
||||
|
||||
|
Code:
echo $PARENT_PATH | awk ' {
arraySize = split($0, parentPath, "/");
delete parentPath[arraySize];
for (i in parentPath ) {
w = w "/" parentPath[i];
}
print w
}'
|
||||
| Google The UNIX and Linux Forums |