Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
concat strings and keep spaces
Name: kuhjaay Date: August 19, 2004 at 13:25:10 Pacific OS: HP-UX CPU/Ram: ?
Comment:
I'm a newbie to unix scripting and I'm trying to find the most efficient way to concatenate two string variables together but to retain the spaces for output to a fixed width file. (I'm using KSH on a Unix platform) ex: var1="99999 " (5 blanks, left justified) var2="01012004"
How can I concat these two vars together and store the value into a var named 'string', w/o losing my spaces? I tried using awk, but maybe my syntax is wrong:
Name: Jim Boothe Date: August 19, 2004 at 14:50:07 Pacific
Reply:
It is just a simple concatenation (string=$var1$var2). But when you echo $string, enclose in double-quotes - otherwise, echo will echo each word separated by a single space.
Summary: Hi Frens, I have to search for a string and need to display a error message if that sting is not found in the file.... I can use the command: > grep "String" filename for searching the string but, in...
Summary: A palindrome could have mixed case, punctuation, and spaces, any of which would mess up a reverse-order test, such as: Are poets a waste? Opera! To check that, your script would have to downshift or u...
Summary: In Bourne shell, is it possible to get the read command to include trailing spaces when reading from files? For the script below, the source files HEADERS and LINES always end each line with trailing ...