Sponsored Content
Top Forums Shell Programming and Scripting BASH: remove digits from end of string Post 302508485 by panyam on Monday 28th of March 2011 09:11:37 AM
Old 03-28-2011
Not sure about the expected output for you!

Code:
 
cat input_file
e1000g123001
e1000g0
nge11101
nge3
$head -1 input_file | sed 's/[0-9]//g'
eg
$head -1 input_file | sed 's/[a-z]//g'
1000123001

 

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
mosy(8) 						      System Manager's Manual							   mosy(8)

NAME
mosy - The managed object syntax compiler. SYNOPSIS
/usr/sbin/mosy [-d] [-i] [-o output_file] [-s] [-1] input_file OPTIONS
Specifies no duplicate entries in the output file. By default, if duplicate entries exist in the input file, they will also exist in the output file. Specifies that errors are ignored. This option causes the mosy program to create an output file even if it encounters errors. The default behavior is that the mosy program generates no output file when errors are encountered. Specifies the file to create for mosy output. If not specified, the output file is derived from the input file name by replacing the suffix with or appending input_file is not specified (or is specified as a hyphen (-) for standard input), output goes to standard output. You can also use a hyphen (-) to specify the output file name, which means output to standard out. Indicates silent mode which turns off the default behavior of printing out objects names, type names, and identifiers. Specifies that the mosy program will perform only the first validation pass when compiling. The mosy program prints the input_file contents as it parses, which is useful when debugging syntax errors. OPERANDS
Specifies a text file in MIB format describing a set of managed objects. If you do not specify an input_file or specify a hyphen (-), the program accepts input from standard input. DESCRIPTION
The mosy program reads a description of an SNMP-managed objects module (extracted from a MIB) and produces a simple ASCII file containing equivalent definitions. The output file is used by various management applications. In particular, mosy output files are used as input to the snmpi program when developing extensible SNMP subagents for Tru64 UNIX. The input_file is typically obtained by cleaning up an RFC file that defines a MIB. (You can use the /usr/examples/esnmp/mib_converter.sh script to perform this task.) For a complete description of using mosy and developing subagents refer to the Network Programmer's Guide. EXAMPLES
Compile the file chess.my with the output going to the file chess.defs. # mosy chess Clean up the MIB defined in RFC1514.txt and compile it, placing the output in file fred.objects # /usr/examples/esnmp/mib-converter.sh < rfc1514.txt > rfc1514.my # /usr/sbin/mosy -o fred.objects rfc1514.my You must copy the /usr/examples/esnmp/mib-converter.sh program to another directory and make it executable in order to perform this operation. FILES
SEE ALSO
Commands: snmpd(8), snmpi(8), snmp_request(8) Network Programmer's Guide IDENTIFICATION
Marshall T. Rose, Performance Systems International This work was partially supported by the U.S. Defense Advanced Research Projects Agency and the Rome Air Development Center of the U.S. Air Force Systems Command under contract number F30602-88-C-0016. It has been modified for use in Tru64 UNIX extensible SNMP. mosy(8)
All times are GMT -4. The time now is 02:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy