Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Cut first value after underscore and replace first two digit with zero in perl Post 303040019 by nadeemrafikhan on Tuesday 22nd of October 2019 02:58:51 AM
Old 10-22-2019
Cut first value after underscore and replace first two digit with zero in perl

Like I have below string

Code:
XX_49154534_491553_201_122023_D
XX_49159042_491738_201_103901_D

and the expected output would be
Code:
0154534
0159042

XX and 49 can be dynamic.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replace one digit by two digit using sed

Folks, Is there a simple way to replace one digit by two digit using sed. Example, mydigit1918_2006_8_8_lag1.csv should be mydigit1918_2006_08_08_lag01.csv. I tried this way, but doesn't work. echo mydigit1989_2006_8_8_lag1.csv|sed 's/]/0]/' Thank you, (5 Replies)
Discussion started by: Jae
5 Replies

2. Shell Programming and Scripting

How to convert a 2 digit to 4 digit

Hi All, How can i convert a number 24 to 0024 In the same way how can i convert 123 to 0123? All this has to be done inside a script Thanks in advance JS (6 Replies)
Discussion started by: jisha
6 Replies

3. Shell Programming and Scripting

Single digit date to double digit date.

I have a var storing date var=`date` Now the date is returned as Mon Feb 2 00:25:48 PST 2009 Is there any way to check the date field alone ("2" in above case) and if its a single digit then add a prefix 0 to it and store the result in same variable "var" My intention in above case is... (3 Replies)
Discussion started by: villain41
3 Replies

4. Shell Programming and Scripting

Cut Data In Bigfile with Perl

I want to create new file for START-END but i know NO 0003/02 only one in file Ex. Data FILE Data.txt (Data ~1,000,000 Line) I use Script perl perl -lne '$/="END";print $_."END" if /0003\/02/' fileOut put script perl but I want create Out put All No in START-END have NO 0003/02 Please... (8 Replies)
Discussion started by: kittiwas
8 Replies

5. Shell Programming and Scripting

Using of gsub function in AWK to replace space by underscore

I must design a UNIX script to monitor files whose size is over a threshold of 5 MB in a specific UNIX directory I meet a problem during the for loop in my script. Some file names contain spaces. ls -lrt | awk '$5>=5000000 && length($8)==5 {gsub(/ /,"_",$9); print};' -rw-r--r-- 1 was61 ... (2 Replies)
Discussion started by: Scofield38
2 Replies

6. 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

7. Shell Programming and Scripting

convert two digit in to single digit...

Hi Guys. My Input: ABCD 12 00 KL ABCD 12 08 DL ABCD 12 10 KK ABCD 12 04 LL ABCD 13 00 LP ABCD 13 1O LS Output: ABCD 12 0 KL ABCD 12 8 DL ABCD 12 10 KK ABCD 12 4 LL ABCD 13 0 LP (2 Replies)
Discussion started by: pareshkp
2 Replies

8. Shell Programming and Scripting

Cut, replace and Paste a String from one file to another

I need to cut all the Strings in one file and Paste it in the another file in the Specific line by replacing the specific String. For Example Step 1: From the newfile.txt, i need to copy all the strings newfile.txt How are you, I am fine, How is your work newfle2.txt Hello david,... (2 Replies)
Discussion started by: Padmanabhan
2 Replies

9. Shell Programming and Scripting

Perl to run different parser based on digit

The perl parser below works as expected assuming the last digit in the NC_ before the . is a single digit. perl -ne 'next if $. == 1; if(/.*del(+)ins(+).*NC_0{4}(+).*g\.(+)_(+)/) # indel { print join("\t", $3, $4, $5, $1, $2), "\n"; } ' out_position.txt > out1.txt ... (8 Replies)
Discussion started by: cmccabe
8 Replies

10. Shell Programming and Scripting

Replace a space with underscore in a file

i have a file with following data. { EqName "Tan 1" .... .... } { EqName "Sin 2" ... ... } I have to replace the value of EqName to Tan_1 and Sin_2 in file.Can i use sed or awk ? cat file|grep EqName|awk '{print $2 $3}'|sed -i 's//_/g' I tried with this but it... (2 Replies)
Discussion started by: Jag02
2 Replies
CURSES_UNDERSCORE(3)					   BSD Library Functions Manual 				      CURSES_UNDERSCORE(3)

NAME
curses_underscore, underscore, underend, wunderscore, wunderend -- curses underscore attribute manipulation routines LIBRARY
Curses Library (libcurses, -lcurses) SYNOPSIS
#include <curses.h> int underscore(void); int underend(void); int wunderscore(void); int wunderend(void); DESCRIPTION
These functions manipulate the underscore attribute on stdscr or on the specified window. The underscore() function turns on the underscore attribute on stdscr. The underend() function turns off the underscore attribute on stdscr. The wunderscore() and wunderend() functions are equivalent to underscore() and underend(), respectively, excepting that the attribute is manipulated on the window specified by win. The underscore() and underend() functions are equivalent to wattron(A_UNDERLINE) and wattroff(A_UNDERLINE), respectively. RETURN VALUES
These functions always return 1. SEE ALSO
curses_attributes(3), curses_standout(3) STANDARDS
The NetBSD Curses library complies with the X/Open Curses specification, part of the Single Unix Specification. HISTORY
These functions first appeared in NetBSD 1.5. BSD
October 13, 2002 BSD
All times are GMT -4. The time now is 12:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy