LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 12-19-2012, 06:10 AM   #1
robertjinx
Member
 
Registered: Oct 2007
Location: Prague, CZ
Distribution: RedHat / CentOS / Ubuntu / SUSE / Debian
Posts: 749

Rep: Reputation: 73
playing with variables (need help)


Hello, I've got a simple variable which will have values similar to this:

VAR1="3270/tty0"
VAR1="3270/tty1"
VAR1="3270/tty3"

and so on. I need to somehow strip it, so I would get only the ending numbers, meaning 0, 1, 3, etc.

So I would need to drop 3270/tty and only end-up with 0, 1, 3. I know is somehow possible, but don't know how.

If anybody knows, help would be appreciated.
 
Old 12-19-2012, 06:21 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Shell parameter expansion is what you're looking for:
Code:
echo ${VAR1##*/tty}
 
Old 12-19-2012, 08:32 AM   #3
robertjinx
Member
 
Registered: Oct 2007
Location: Prague, CZ
Distribution: RedHat / CentOS / Ubuntu / SUSE / Debian
Posts: 749

Original Poster
Rep: Reputation: 73
Thanks that help!
 
  


Reply



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
Screen capture while playing video yields to blue window where video is playing kayasaman Linux - Desktop 10 01-19-2012 09:54 AM
Bash Script: parse active process stderr, strip, dump into variables, use variables TimeFade Programming 1 02-13-2010 06:09 AM
Threads synchronisation problem (mutex variables and contitional variables) zahadumy Programming 6 12-07-2005 12:30 PM
Totem playing off of network, Xine playing local iammike Ubuntu 0 04-30-2005 11:43 AM
Shel scripting: variables pointing to variables and case Dark_Helmet Programming 5 06-08-2003 11:07 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:38 AM.

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
Open Source Consulting | Domain Registration