![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to replace any char with newline char. | mightysam | Shell Programming and Scripting | 5 | 09-18-2008 08:15 PM |
| last char from a string | broli | Shell Programming and Scripting | 6 | 12-07-2007 08:02 PM |
| char c = 882 | useless79 | High Level Programming | 1 | 07-30-2007 05:16 AM |
| char *p and char p[]. | arunviswanath | High Level Programming | 4 | 07-20-2006 02:11 AM |
| \n char in C | C|[anti-trust] | High Level Programming | 1 | 05-05-2005 06:15 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
get the last 2 char from a variable
i have 2 variables
VAR1=12345_SNT.in1 VAR2=123456_LXP.in2 how can i get the last 2 characters before the . for VAR1, i only want to get the NT for VAR2, i only want to get the XP the length of the variable varies, so does its extension. the only thing that is consistent is the "." thanks! |
|
||||
|
Quote:
just to understant things... what does this mean? sed 's/.*\(..\)\..*/\1/' |
|
||||
|
Code:
sed = stream editor general form = s/search expression/replace expression/ search expression = .* matches any string of characters \(..\) matches exactly two characters and preserves the matching values in a place holder \. matches exactly one period; your constant .* matches the remainder of the string replace expression = \1 only inserts the entire string that was contained in \( and \) |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|