Sponsored Content
Top Forums Shell Programming and Scripting BASH: remove digits from end of string Post 302508569 by alister on Monday 28th of March 2011 01:06:49 PM
Old 03-28-2011
A portable sh alternative:
Code:
device=e1000g123001
INSTANCE=${device##*[[:alpha:]]}
mask=
while [ ${#mask} -ne ${#INSTANCE} ]; do
        mask=$mask?
done
DRIVER=${device%$mask}

Regards,
Alister

---------- Post updated at 01:06 PM ---------- Previous update was at 12:57 PM ----------

A bash alternative:
Code:
device=e1000g123001
INSTANCE=${device##*[[:alpha:]]}
DRIVER=${device:0:$((${#device}-${#INSTANCE}))}

Regards,
Alister
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extract digits at end of string

I have a string like xxxxxx44. What's the best way to extract the digits (one or more) in a ksh script? Thanks (6 Replies)
Discussion started by: offirc
6 Replies

2. Shell Programming and Scripting

Remove / at the end of a string if it exists

Hey guys, Can sed or another command be used to examine a path such as /home/test/blah/blahand check to see if the last character is a "/" and if so remove it So this is what should happen: /home/test/blah/blahnothing happens, this is ok /home/test/blah/blah/the "/" at the end is... (6 Replies)
Discussion started by: tret
6 Replies

3. Shell Programming and Scripting

Remove box like special character from end of string

Hi All, How to remove a box like special character which appears at the end of a string/line/record. I have no clue what this box like special character is. It is transparent square like box. This appears in a .DAT file at the end of header. I'm to compare a value in header with a parameter.... (16 Replies)
Discussion started by: Qwerty123
16 Replies

4. Shell Programming and Scripting

Awk: Remove comma at the end of the string

Hi i had String like UID: ABC345QWE678GFK345SA90, LENGTH 32 when I used awk ' FS, {print $1}' prints ABC345QWE678GFK345SA90, how can i getrid of that coma at the end of the string. Thanks in advance.. (14 Replies)
Discussion started by: Reddy482
14 Replies

5. Shell Programming and Scripting

Search and remove digits (if exist) from end of the string

Hi Experts, Here is what I am trying to do. 1) say I have a file with below strings database1 database2 database3 data10gdb1 data10gdb2 databasewithoutdigit 2) I want to get the below output. (- if there is any digit at the end of the string, I need to remove it) (- Any... (3 Replies)
Discussion started by: shail_boy
3 Replies

6. Shell Programming and Scripting

How to remove white spaces from the beginning an end of a string in unix?

Suppose, I have a variable var=" name is ". I want to remove the blank spaces from the begining and endonly, not from the entire string. So, that the variable/string looks like following var="name is". Please look after the issue. (3 Replies)
Discussion started by: mady135
3 Replies

7. Shell Programming and Scripting

Remove lines that match string at end of column

I have this: 301205 0000030000041.49000000.00 2011111815505 908 301205 0000020000029.10000000.00 2011111815505 962 301205 0000010000027.56000000.00 2011111815505 3083 312291 ... (2 Replies)
Discussion started by: herot
2 Replies

8. Shell Programming and Scripting

Remove 3rd character from the end of a random-length string

Hi, I hope someone can share there scripting fu on my problem, I would like to delete the 3rd character from a random length of string starting from the end Example Output Hope you can help me.. Thanks in advance.. (3 Replies)
Discussion started by: jao_madn
3 Replies

9. Shell Programming and Scripting

Remove lines between the start string and end string including start and end string Python

Hi, I am trying to remove lines once a string is found till another string is found including the start string and end string. I want to basically grab all the lines starting with color (closing bracket). PS: The line after the closing bracket for color could be anything (currently 'more').... (1 Reply)
Discussion started by: Dabheeruz
1 Replies

10. Shell Programming and Scripting

How can I extract digits at the end of a string in UNIX shell scripting?

How can I extract digits at the end of a string in UNIX shell scripting or perl? cat file.txt abc_d123_4567.txt A246_B789.txt B123cc099.txt a123_B234-012.txt a13.txt What can I do here? Many thanks. cat file.txt | sed "s/.txt$//" | ........ 4567 789 099 012 13 (11 Replies)
Discussion started by: mingch
11 Replies
ddi_intr_set_mask(9F)													     ddi_intr_set_mask(9F)

NAME
ddi_intr_set_mask, ddi_intr_clr_mask - set or clear mask for a given interrupt SYNOPSIS
#include <sys/types.h> #include <sys/conf.h> #include <sys/ddi.h> #include <sys/sunddi.h> int ddi_intr_set_mask(ddi_intr_handle_t h); int ddi_intr_clr_mask(ddi_intr_handle_t h); INTERFACE LEVEL
Solaris DDI specific (Solaris DDI). h DDI interrupt handle The ddi_intr_set_mask() function masks the given interrupt pointed to by the device's interrupt handle h if the device or host bridge sup- ports the masking operation. The ddi_intr_get_cap() function returns the RO flag DDI_INTR_FLAG_MASKABLE if the device or host bridge sup- ports interrupt mask bits for the given interrupt type. In flight interrupts can still be taken and delivered to the driver. The ddi_intr_clr_mask() function unmasks the given interrupt pointed by the device's interrupt handle h if the device or host bridge sup- ports the masking operation. The ddi_intr_get_cap() function returns the RO flag DDI_INTR_FLAG_MASKABLE if the device or host bridge sup- ports interrupt mask bits for the given interrupt type. The mask cannot be cleared directly if the OS implementation has also temporarily masked the interrupt. A call to ddi_intr_clr_mask() must be preceded by a call to ddi_intr_set_mask(). It is not necessary to call ddi_intr_clr_mask() when adding and enabling the interrupt. The system framework will clear any device or host bridge mask bits when the interrupt is initially enabled. The ddi_intr_set_mask() and ddi_intr_clr_mask() functions return: DDI_SUCCESS On success. DDI_EINVAL On encountering invalid input parameters. DDI_FAILURE On any implementation specific failure. DDI_ENOTSUP On device not supporting operation. CONTEXT
The ddi_intr_set_mask() and ddi_intr_clr_mask() functions can be called from any context. See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ attributes(5), ddi_intr_block_disable(9F), ddi_intr_block_enable(9F), ddi_intr_disable(9F), ddi_intr_enable(9F), ddi_intr_get_pending(9F) Consumers of these interfaces should verify that the return value is not equal to DDI_SUCCESS. Incomplete checking for failure codes could result in inconsistent behavior among platforms. 22 Apri 2005 ddi_intr_set_mask(9F)
All times are GMT -4. The time now is 11:07 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy