Concat strings without spaces...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Concat strings without spaces...
# 1  
Old 09-14-2015
Concat strings without spaces...

Hello,

I have a very travial question....when i run the below script...how can i change my script that will give me an output pf "this is log_vp1" ....i dont want any spaces between log_vp and 1 or any other character...i know i can set a variable for 1(lets say num is the var) and then do $lv$num but i cant do that...this need to be hardcoded...

Code:
# cat test.sh
lv=log_vp

echo "this is $lv+1"
#
# ./test.sh
this is log_vp+1
#

# 2  
Old 09-14-2015
Code tags for code please, [code]stuff[/code]

What you describe is exactly what hardcoded is... I think you mean dynamic, as in, the name needs to change next time the program runs? What determines how the name changes?
# 3  
Old 09-14-2015
Code:
$ lv=log_vp
$ lv+=1
$ echo $lv
$ log_vp1

Code:
$ lv=log_vp
$ echo ${lv}1
$ log_vp1

This User Gave Thanks to Aia For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Can I combine below mentioned grep commands using OR (when searching strings having spaces)

Command 1: $script | grep 'Write to ECC( SSID=MARGIN)' Command 2: $script | grep 'is not greater than existing logical processing' The above commands run my script and search the mentioned strings but I do not want to run my script twice. It is increasing run time. Can someone tell me... (3 Replies)
Discussion started by: Tanu
3 Replies

2. Shell Programming and Scripting

Concat

Hi All, My Input file contains: Input.txt Name|Marks ABC|10 GHI|10 JKL|20 MNO|20 PQR|30 Output.txt MARKS|NAME 10|ABC,GHI 20|JKL,MNO 30|PQR Thanks in advance (4 Replies)
Discussion started by: kmsekhar
4 Replies

3. Solaris

Concat strings in Sun Solaris

Hi I am using solaris 10 #!/bin/ksh today=`date` GrepDate=`echo $today | awk '{print $1,$2,$3}'` echo $GrepDate output is "Mon Mar 8" But i need to get output like "Mon Mar 8"(two spaces b/w Mar & 8) Please help Regards Arun (6 Replies)
Discussion started by: annyarun
6 Replies

4. Shell Programming and Scripting

Treating Strings with spaces

I have a file list.txt which has a list of file names with spaces between the file names like /emptydir/file 1 how do i browse through the list.txt displaying the filenames. Almost all the file names in list.txt have space between them.This file list.txt is formed by using the find statement to... (5 Replies)
Discussion started by: kinny
5 Replies

5. Shell Programming and Scripting

Replace spaces between strings in a line with tab

Hi All I am having problem in substitution of any number of spaces, or a combination of space and tab in between strings in the lines of text file. Is there any way out in Perl? Please help me. e.g., Say the input is in the following format:- XX yyy zzz... (1 Reply)
Discussion started by: my_Perl
1 Replies

6. Programming

Concatenating array of strings into one string separated by spaces

Hi, Well as the title says, I have an array of strings (delimited by null). The length of the array is variable and length of each string is variable as well. What I need is one huge string with the original strings in the array separated by spaces. For example is an array is such that array... (12 Replies)
Discussion started by: newhere
12 Replies

7. Shell Programming and Scripting

ksh: Comparing strings that contain spaces and working with substrings

Forgive me. I am very new to kornshell scripts. The simplest things stop me dead in my tracks. Here are two such examples. I want to save the first 19 characters of the following string to a variable. "Operation Completed and blah blah blah" I know this works (from another thread): ... (2 Replies)
Discussion started by: nancylt723
2 Replies

8. Shell Programming and Scripting

concat strings

Hello, I have a list of tablespaces in oracle and I want to concatenate 'drop tablespace' on the left of each line and 'INCLUDING CONTENTS AND DATAFILES' on the right of each line. Any idea how to do that? many thanks. PS: I tried to use excel and copy/paste it to vi. But I noticed many... (1 Reply)
Discussion started by: melanie_pfefer
1 Replies

9. UNIX for Dummies Questions & Answers

How to append "spaces" between strings

HI, Supose I have the folowing strings: "unix" and "linux". I want to concatenate the two strings, inserting between them a variable number of spaces. ex1: unix linux ex2: unix linux Can you help me in this simple problem? Regards, Elio (2 Replies)
Discussion started by: efernandes
2 Replies

10. UNIX for Dummies Questions & Answers

Append strings with filler spaces

Hi I am looping through the contents of a file as follows cat file |while read inrec do echo $inrec >> $TMP done (obviously this isn't all i am doing as it would be pointless but for the sake of the problem this is the important bit) The file has fields which are separated by... (1 Reply)
Discussion started by: handak9
1 Replies
Login or Register to Ask a Question