Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Using awk, how to 'properly' print the rest of the string? Post 303045361 by newbie_01 on Wednesday 18th of March 2020 06:49:28 AM
Old 03-18-2020
Thanks as usual RudiC. I used the sub option instead



Code:
   BEGIN {
         for ( i = split( "JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC", month ) ; i ; i-- )
         mdigit[month[i]] = i
      }
      {
         sub ( $1 FS $2, sprintf( "%04d-%02d-%02d=",substr($1,8,4),mdigit[substr($1,4,3)],substr($1,1,2) ) $2 )
         print
      }

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

SED Exclude Matches Between Pattern1 And Pattern2 Containing Pattern3 Print The Rest

Hi, From the sample file below Conditions 1) Pattern Range must start with "ALTER TABLE" 2) Pattern Range ends when it finds ";" 3) Between this range i want to select all the patterns that contain pattern " MOVE " Note : I would like to exclude the above pattern matches and print... (1 Reply)
Discussion started by: rajan_san
1 Replies

2. UNIX for Dummies Questions & Answers

AWK...find a string ,if so print it

Hi, I need to find a string, if it finds then I need to print it , otherwise it has to goto next line.... input is====> uid = shashi, india uid ,uid= asia uid= none, uid=india. none ========== output shold be uid = shashi, india uid , uid= asia uid= none, uid=india. none ... (1 Reply)
Discussion started by: hegdeshashi
1 Replies

3. Shell Programming and Scripting

Search a string and print the rest of line

Hi Guys, I need to search a string and print the rest of the lines... input: 8 0 90 1 0 59 20 2488 96 30006dde372 S ? 0:00 /etc/opt/SUNWconn/atm/bin/atmsnmpd -n output: 00 /etc/opt/SUNWconn/atm/bin/atmsnmpd -n Actually i don even need the first "00".. any suggestions is appreciated..... (13 Replies)
Discussion started by: mac4rfree
13 Replies

4. Shell Programming and Scripting

awk print second line after search string

I have multiple config files where I need to pull the ip address from loopback3. The format is the same in every file, the ip is the second line after interface loopback3. interface loopback2 loopback description router ID ip address 192.168.1.1 interface loopback3 loopback description... (3 Replies)
Discussion started by: numele
3 Replies

5. Shell Programming and Scripting

How to print 1st field and last 2 fields together and the rest of the fields after it using awk?

Hi experts, I need to print the first field first then last two fields should come next and then i need to print rest of the fields. Input : a1,abc,jsd,fhf,fkk,b1,b2 a2,acb,dfg,ghj,b3,c4 a3,djf,wdjg,fkg,dff,ggk,d4,d5 Expected output: a1,b1,b2,abc,jsd,fhf,fkk... (6 Replies)
Discussion started by: 100bees
6 Replies

6. Shell Programming and Scripting

awk find and print next string

Can I do this in one awk session. Solution I have is poor. I want to return the number after PID. echo "Start: 12345 is used by PID:11111 username" | awk -F: '{print $3}' | awk '{print $1}' (6 Replies)
Discussion started by: u20sr
6 Replies

7. Shell Programming and Scripting

awk print string with removing all spaces

Hi all, I want to set 10 set of strings into a variable where: removing all spaces within each string change the delimiter from "|" to "," Currently, I've the below script like this:Table=`ten character strings with spaces in-between and each string with delimiter "|" | tr -d ' ' |... (7 Replies)
Discussion started by: o1283c
7 Replies

8. UNIX for Dummies Questions & Answers

Tree command does not print properly

Hi, when I run tree command in linux box getting below image, not the line test âââ lost+found âââ test1 â  âââ aaa.txt â  âââ bbb.txt âââ test2 3 directories, 2 files installed tree-1.5.3-2.el6.x86_64 package (8 Replies)
Discussion started by: stew
8 Replies

9. Shell Programming and Scripting

awk to print string if tag is specific value

In the below awk I am trying to print expName only if another tag planExecuted is true. In addition to the expName I am also printing planShortID. For some reason the word experiment gets printed so I remove it with sed. I have attached the complete index.html as well as included a sample of it... (1 Reply)
Discussion started by: cmccabe
1 Replies

10. Shell Programming and Scripting

awk print not working properly

Hello friends, There is one requirment where I need to login into database environment and pull all schema names into a text file ... as of now below are the schemas available... $> describe keyspaces; system_schema system_auth system abc system_distributed system_traces Now from... (4 Replies)
Discussion started by: onenessboy
4 Replies
IM::Scan(3pm)						   Internet Message Perl modules					     IM::Scan(3pm)

NAME
IM::Scan - scan listing from mail/news message SYNOPSIS
use IM::Scan; &set_scan_form($scan_form, $width, $use_jis); &read_petnames(); %Head = &get_header($mail_file); &disp_msg(\%Head); DESCRIPTION
The IM::Scan module handles scan format and petnames format for mail/news message. This modules is provided by IM (Internet Message). FILES
$HOME/.im/Config the user profile PROFILE COMPONENTS
Component Explanation Example MailDir: your mail directory Mail Width: one line width 80 JisSafe: safely substr for ISO-2022-JP on Form: scan format %+5n %m%d %8f %-30S %b PetnameFile: nickname file ~/.im/Petname Address: your mail addresses kazu@mew.org, kazu@wide.ad.jp AddrRegex: regexp of your addresses ^kazu@.*$ if necessary SCAN FORMAT
'%{width}{header-type}' format is available. You can define any header-type as you want. Default valid header-types are %n message number %d raw Date: field %f MIME decoded From: field %t MIME decoded To: filed %g raw Newsgroups: field %a friendly From: field %A If this message is originated by yourself, friendly To: or raw Newsgroups: is displayed in 'To:xxx' or 'Ng:xxx' format, respectively. Otherwise, friendly From: field is displayed. %P Similar to %A, but display raw address of mail sender instead of friendly From: field, just like mh-e. %i indent to display thread %s MIME decoded Subject: field %S indented MIME decoded Subject (same as %i+%s) %b a part of body extracted with heuristic %m Multipart type 'S'igned, 'E'ncrypt, 'M'ultipart, 'P'artial or none %p mark '*' if the message is destined to you %D mark 'D' if the message is duplicated %M %p+%D %F folder path %K file block size (1024 bytes/block) %y year %c month (digit) %C month (string) %e mday %h hour %E min %G sec {width} is a integer with/without '-' sign. if a '-' sign exists, content of a header-type will be displaied with left adjustment. If the integer have leading '0', the field will be padded with leading '0's. To improve processing speed, needless process on JIS character should be avoided. Even if 'JisSafe' is on, only %f, %t, %A, %s, %S and %b are processed with 'substr' routine for JIS characters by default. If you want to process other header-types with JIS version of 'substr', specify '!' just after '%' like: %!-8S. ScanForm "%+5n %m%d %-14A %-18S %b" works as same as IM default scaning. PETNAMES FORMAT
Following format is valid in petnames file. A line beginning with '#' is ignored. # This is comments Kazu@Mew.org "Mr.Kazu" nom@Mew.org "Nomsun" COPYRIGHT
IM (Internet Message) is copyrighted by IM developing team. You can redistribute it and/or modify it under the modified BSD license. See the copyright file for more details. IM151 2011-05-25 IM::Scan(3pm)
All times are GMT -4. The time now is 07:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy