Search Results

Search: Posts Made By: tostay2003
14,318
Posted By RudiC
Not quite sure what you mean by "above result"....
Not quite sure what you mean by "above result". However, try sed -rn 's/[^0-9]*([0-9]{1,})[^0-9]*.*/\1/p' file
14,318
Posted By bakunin
Exactly: [AB] # matches "A" or "B" ...
Exactly:

[AB] # matches "A" or "B"
[^AB] # matches any character except "A" or "B"

You need this quite often, because matches in sed are always "greedy". Suppose the following text:
...
14,318
Posted By Scrutinizer
Or to get the first field with numbers, try: ...
Or to get the first field with numbers, try:
sed -n 's/^\([^0-9.].\)*\([0-9]*\).*/\2/p'
or if is always the second field, try:
cut -d. -f2
14,318
Posted By Aia
echo "testing.123.xyz.456.txt" | sed -n...
echo "testing.123.xyz.456.txt" | sed -n 's/.*\.\([0-9]\{1,\}\)\..*/\1/p'

The issue is that the red part of the regex matches the part of the string. The `.*' will try to match as much as it can.
...
10,975
Posted By neutronscott
POSIX sh doesn't support that notation but often...
POSIX sh doesn't support that notation but often you can emulate it with short string using something like this:


$ v=substring
$ echo ${v:1:3}
sh: 2: Bad substitution
$ echo ${v%${v#???}}
sub
10,975
Posted By Don Cragun
The substring expansions are not available in the...
The substring expansions are not available in the 1988 version of ksh. Does your system include a command called ksh93?
1,077
Posted By anbu23
vDate=`echo $filename | sed -n...
vDate=`echo $filename | sed -n 's/.*\.\([0-9]\{1,\}\)\..*/\1/gp'`
Showing results 1 to 7 of 7

 
All times are GMT -4. The time now is 09:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy