How to print only the digit in between a line in UNIX?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to print only the digit in between a line in UNIX?
# 1  
Old 09-03-2015
Wrench How to print only the digit in between a line in UNIX?

Below is my content in a file. How to print only the number in between CURDEPTH( ) ?? Please help me

Code:
5724-H72 (C) Copyright IBM Corp. 1994, 2011.  ALL RIGHTS RESERVED.
Starting MQSC for queue manager


     1 : dis ql(DUMMY.QUEUE) curdepth
AMQ8409: Display Queue details.
   QUEUE(DUMMY.QUEUE)
   TYPE(QLOCAL)                            CURDEPTH(1)
One MQSC command read.
No commands have a syntax error.
All valid MQSC commands were processed.


Last edited by Scrutinizer; 09-03-2015 at 04:04 PM.. Reason: code tags
# 2  
Old 09-03-2015
It all depends what you are going to do with it. As an example this does:

Code:
perl -nle '/CURDEPTH\((\d+)\)/ and print $1' prince1987.file

Edit: Added a + to accommodate that a number could be more than one digit

Last edited by Aia; 09-03-2015 at 03:56 PM..
This User Gave Thanks to Aia For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to match the first word and print only that line in UNIX?

Below is the file DISK-A 109063.2 49 31 40.79 DISK-B 110058.5 49 44 57.07 DISK-c 4402.4 2 1 2.14 from the file, i want to search for 'DISK-A' and print only that line with the first word matching to DISK-A and the output should skip DISK-A. Desired Output: (If i'm... (2 Replies)
Discussion started by: web2moha
2 Replies

2. Shell Programming and Scripting

Regular expression for 6 digit number present in a line

Hello Team, i have a file test1.txt, in which i have to grep only the 6 digit number from it, Could you pls help in this. $cat test1.txt <description>R_XYZ_1.6 r370956</description> $ grep "\{6\}" test1.txt <description>R_XYZ_1.6 r370956</description> i need output as 370956. ... (3 Replies)
Discussion started by: chandana hs
3 Replies

3. Shell Programming and Scripting

Print a number up to last significant digit after decimal point

I want to write/print a number through a shell script up to its last significant digit (LSD) after the decimal point. Say, x=10.00056000000000000 I want to print x as x=10.00056. Note that x can be any thing so I cannot know the position of the LSD always. Thanks. (16 Replies)
Discussion started by: hbar
16 Replies

4. Shell Programming and Scripting

how to delete the line if the first letter is a single digit

Hi, I'm trying to acheive the following, I have a dat file in which i have several addresses, If the address starts with a single digit then i have to delete the line, if it starts with 2 or more digits then i have to keep the line Here is a sample of my file: 377 CARRER DE LA... (5 Replies)
Discussion started by: ramky79
5 Replies

5. Shell Programming and Scripting

awk length of digit and print at most right digit

Have columns with digits and strings like: input.txt 3840 3841 3842 Dav Thun Tax Cahn 146; Dav. 3855 3853 3861 3862 Dav Thun Tax 2780 Karl VI., 3873 3872 3872 Dav Thun Tax 3894 3893 3897 3899 Dav Thun Tax 403; Thun 282. 3958 3959 3960 Dav Thun Tax 3972 3972 3972 3975 Dav Thun Tax... (8 Replies)
Discussion started by: sdf
8 Replies

6. Shell Programming and Scripting

how to add single digit in front of the word and line in the file.

Hi , how to add the single digit to front of the word and front of the lines in the one file with compare pattern file and get digit. like example pattern file pattern.txt pattern num bala 2 raja 3 muthu 4 File Name: chennai.dat muthu is good boy raja is bad boy selvam in super... (6 Replies)
Discussion started by: krbala1985
6 Replies

7. Shell Programming and Scripting

Print the different line from two files in unix

Hi all, I have a two files ... the first file contain "ls -la " output on directory. second file contains " ls -la " output on the same directory but after removing some files from the directory.... how to get the file names that are removed ....... the total no of files are more than 1000 so... (2 Replies)
Discussion started by: firestar
2 Replies

8. UNIX for Dummies Questions & Answers

How to get 4 digit Year using ls -l in HP-Unix

I have this code that loops through a directory and adds all the files it finds in a log file. # get list of files from FTP server; stores # 'ls -l' results in $FTP_RESULTS ( echo user ${FTP_USER} ${FTP_PASSWD} echo cd ${FULL_PATH} echo ls -l echo bye )|ftp -i -n... (3 Replies)
Discussion started by: akabir77
3 Replies

9. UNIX for Dummies Questions & Answers

Append 0 for single digit entered from command line

I have a script like this-- #!/bin/ksh echo "To pad a 0 before digits from 1-9" for i in $* do echo $i | sed 's//'0'/g' done I run this script as ksh name 1 2 23 34 The output should be 01 02 23 34 Help me in modifying this script. Thanks Namish (2 Replies)
Discussion started by: namishtiwari
2 Replies

10. Shell Programming and Scripting

How to print all lines that has exactly 3 occurences of digit 4 using grep?

How to print all lines that has exactly 3 occurences of digit 4 using grep? I am able to find the pattern if it is for atleast 3 occurences but with exactly 3 occurences? Can anybody help me on this. (3 Replies)
Discussion started by: sivasai83
3 Replies
Login or Register to Ask a Question