473,407 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

How to manipulate a string, variable in shell

3
Hei everyone!

I have this variable in shell containing paths separated by
a space:

Expand|Select|Wrap|Line Numbers
  1. LINE="/path/to/manipulate1 /path/to/manipulate2"
  2.  
I want to add additional path string in the beginning of the string and as well right after the space so that the variable will have the result something like this:

Expand|Select|Wrap|Line Numbers
  1. LINE="/additional/path1/to/path/to/manipulate1 /additional/path2/to/path/to/manipulate2"
  2.  
Any help appreciated
Thanks in advance
Dec 30 '10 #1
3 2229
rski
700 Expert 512MB
Do you want o to add two different directories?
/additional/path1
/additional/path2
Do this path can be somehow calculated from original paths, is this correlation ok
Expand|Select|Wrap|Line Numbers
  1. /path/to/manipulate1 -> add /additional/path1
  2. /path/to/manipulate2 -> add /additional/path2
  3. /path/to/manipulate3 -> add /additional/path3
  4. ...
  5.  
Jan 4 '11 #2
numberwhun
3,509 Expert Mod 2GB
To add paths to the variable in the shell, simply do the following:

Expand|Select|Wrap|Line Numbers
  1. export LINE = "$LINE /new/path/1 /new/path/2"
  2.  
You first put the current variable in the list and then add any after it.

Regards,

Jeff
Jan 11 '11 #3
$ LINE="/path/to/manipulate1 /path/to/manipulate2"
$ set -- $LINE
$ LINE="/additional/path1/to$1 /additional/path2/to$2"
Jan 11 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: PK9 | last post by:
I have a string variable that holds the equivalent of a DateTime value. I pulled this datetime from the database and I want to strip off the time portion before displaying to the user. I am...
1
by: Martin Heal | last post by:
I am having problems trying to assign the contents of a Memo table field to a String variable in VB using the following code: Private Function udfBuildSQL(SQLID As Integer) As Variant Dim rs...
3
by: XenofeX | last post by:
How can i call to object from string variable ? For instance string x = "textBox1"; i want to call the object which name is stored in the x string variable. The most important thing is the...
1
by: Hose B | last post by:
HI all, I have a legacy app in which users can pick various page templates. There is a template preview dialog. It works such that they view a list of icons in an asp page that represent each...
4
by: JohnR | last post by:
Hi all, I'm finally sick and tired of manually generating get/set properties for each private variable in a class so I'm trying to create a macro to do it. I'm stuck because I can't figure out...
6
by: John Kotuby | last post by:
Hi all, I am using a 3rd party program in a VS2005 web project. The tool takes as input a string containing HTML and converts it to RTF. I have been creating a page by dynamically loading...
2
by: Looch | last post by:
All, I'm trying to output but I can only get (brackets for clarity) when using the code below. How can I "break" into the query variable in the InsertName method to add the name parameter to...
0
by: Jimis | last post by:
Hello. My objective is to validade a xml file against the xsd whitch is in a string variable. /* book.xml <?xml version="1.0" encoding="utf-8"?> <author xmlns='urn:bookstore-schema'...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.