LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-14-2003, 06:30 AM   #1
liguorir
Member
 
Registered: May 2003
Posts: 256

Rep: Reputation: 30
Question Dropping Characters - kshell


For the following string, how do I drop the first and last characters in kshell? Note characters to be dropped are '(' and ')'

(robert)
 
Old 11-14-2003, 07:35 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
Code:
#!/usr/bin/ksh

RAWNAME="(robert)"

echo "Original:"
echo ${RAWNAME}
echo "Stripped:"
echo ${RAWNAME} | sed 's/[()]//g'
$ ./blaat.ksh
Original:
(robert)
Stripped:
robert
 
Old 11-15-2003, 10:17 PM   #3
liguorir
Member
 
Registered: May 2003
Posts: 256

Original Poster
Rep: Reputation: 30
Question Excellent... now adding more!

Excellent, now how do I add this:

export DISPLAY=robert:0.0

to this

robert
 
Old 11-16-2003, 06:22 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
If you want to go from
(robert)
to
export DISPLAY=robert:0.0
you can use sed (see first example). Replace the ( with export DISPLAY= and the ) with :0.0.

If robert has been assigned to a variable (i.e. NAME="robert") you can use echo:
echo "export DISPLAY=${NAME}:0.0"
 
  


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
Default GW keeps dropping fishy Linux - Networking 2 09-15-2005 03:25 AM
How find which command has been executed by which user. HPUX 11.11 OS kshell murugesan Linux - Distributions 3 04-16-2004 06:26 AM
Connection keeps dropping slakmagik Linux - General 3 04-30-2003 02:26 PM
dropping connection estranged0877 Linux - Networking 2 04-01-2003 06:11 AM
kshell in path & .bash_profile dmartinez Linux - Newbie 3 03-31-2003 11:15 PM


All times are GMT -5. The time now is 06:36 PM.

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