Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Cut first value after underscore and replace first two digit with zero in perl Post 303040039 by Neo on Tuesday 22nd of October 2019 08:44:10 AM
Old 10-22-2019
Please show your own work.

UNIX.com is not a "script writing service" .

We are here to help you learn to admin and write scripts for your servers and systems.

So, please post the code you have written, sample input, output and any error messages.
 

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
LEARN(1)						      General Commands Manual							  LEARN(1)

NAME
learn - computer aided instruction about UNIX SYNOPSIS
learn [ -directory ] [ subject [ lesson ] ] DESCRIPTION
Learn gives Computer Aided Instruction courses and practice in the use of UNIX, the C Shell, and the Berkeley text editors. To get started simply type learn. If you had used learn before and left your last session without completing a subject, the program will use information in $HOME/.learnrc to start you up in the same place you left off. Your first time through, learn will ask questions to find out what you want to do. Some questions may be bypassed by naming a subject, and more yet by naming a lesson. You may enter the lesson as a number that learn gave you in a previous session. If you do not know the lesson number, you may enter the lesson as a word, and learn will look for the first lesson containing it. If the lesson is `-', learn prompts for each lesson; this is useful for debugging. The subject's presently handled are files editor vi morefiles macros eqn C There are a few special commands. The command `bye' terminates a learn session and `where' tells you of your progress, with `where m' telling you more. The command `again' re-displays the text of the lesson and `again lesson' lets you review lesson. There is no way for learn to tell you the answers it expects in English, however, the command `hint' prints the last part of the lesson script used to evaluate a response, while `hint m' prints the whole lesson script. This is useful for debugging lessons and might possibly give you an idea about what it expects. The -directory option allows one to exercise a script in a nonstandard place. FILES
/usr/share/learn subtree for all dependent directories and files /usr/tmp/pl* playpen directories $HOME/.learnrc startup information SEE ALSO
csh(1), ex(1) B. W. Kernighan and M. E. Lesk, LEARN - Computer-Aided Instruction on UNIX BUGS
The main strength of learn, that it asks the student to use the real UNIX, also makes possible baffling mistakes. It is helpful, espe- cially for nonprogrammers, to have a UNIX initiate near at hand during the first sessions. Occasionally lessons are incorrect, sometimes because the local version of a command operates in a non-standard way. Occasionally a lesson script does not recognize all the different correct responses, in which case the `hint' command may be useful. Such lessons may be skipped with the `skip' command, but it takes some sophistication to recognize the situation. To find a lesson given as a word, learn does a simple fgrep(1) through the lessons. It is unclear whether this sort of subject indexing is better than none. Spawning a new shell is required for each of many user and internal functions. The `vi' lessons are provided separately from the others. To use them see your system administrator. 7th Edition October 22, 1996 LEARN(1)
All times are GMT -4. The time now is 01:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy