Sponsored Content
Top Forums UNIX for Beginners Questions & Answers awk script to extract a column, replace one of the header and replace year(from ddmmyy to yyyy) Post 303034963 by anbu23 on Friday 10th of May 2019 07:30:52 AM
Old 05-10-2019
Code:
$ awk -F, -v yr='"YEAR"' ' { $0=$0 OFS (NR == 1 ? yr : "20" substr($0,length($0)-2,3)) } 1 ' OFS=","  file
"abc","sdf","sdf","we","qe","fr","ty","hgf","er","jy","END_DATE","YEAR"
"123","","234","ety","","ghj","tyu","Inh","dn","ngnh","17-FEB-19",2019"

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

changing YYYY-MM-DD to DDMMYY

Hi all Wonder if you can help , I have a comma delimited file where the 13th to the 31st character of each line is populated by the date and time."2004-07-21 09:39:06" 16-5-141551,2004-07-21 09:39:06,8815 22-5-340394,2004-07-22 09:39:41,8001 22-5-340433,2004-07-23 09:42:20,1701 I have... (3 Replies)
Discussion started by: hcclnoodles
3 Replies

2. Shell Programming and Scripting

awk/sed column replace using column header - help

$ cat log.txt Name Age Sex Lcation nfld alias xsd CC 25 M XYZ asx KK Y BB 21 F XAS awe SS N SD 21 M AQW rty SD A How can I replace the column with header "Lcation" with the column with header "alias" and delete the "alias" column? so that the final output will become: Name Age Sex... (10 Replies)
Discussion started by: jkl_jkl
10 Replies

3. Shell Programming and Scripting

awk to replace part of a column

dear all, I'm trying to use Awk to eliminate the last two characters from the first column in a file. This two characters are "-1" and I need to eliminate them from each row that I have in the files. The files have two columns and look like: ID_090-1 2 ID_3787-1 4 ID_0098-1 1 ID_12-1 4 I... (4 Replies)
Discussion started by: gabrysfe
4 Replies

4. Shell Programming and Scripting

Replace the nth column date as MM/DD/YYYY

Hi, I need some unix command to replace the following thing. cat test.dat 1234|test|8/19/2009|8/20/2009|test 1234|test|8/9/2009|8/21/2009|test 1234|test|8/1/2009|8/2/2009|test after processing 1234|test|08/19/2009|08/20/2009|test 1234|test|08/09/2009|08/21/2009|test... (6 Replies)
Discussion started by: anshaa
6 Replies

5. Shell Programming and Scripting

How to Replace the value of a column using awk command?

Hi cat test.txt H|123|341|567|asfg D|dfg|trtyy|errt D|ert|frty|wer Here I need to replace the third column value with 100 of the first record only and while printing I need to print the full file content also..I am expecting a result like this H|123|100|567|asfg D|dfg|trtyy|errt... (3 Replies)
Discussion started by: saj
3 Replies

6. Shell Programming and Scripting

Replace a column with a value by ignoring the header lines

i have a file in the gz format , the content of the file is as follow. gzcat f1.gz # 1.name # 2.location # 3.age # 4.dob . . . . . . . . . # 43.hobbies < Aravind,33,chennai,09091980, , , , , , , surfing> (5 Replies)
Discussion started by: aravindj80
5 Replies

7. Shell Programming and Scripting

Trying to get an awk script to replace values in column

I'm trying to make an awk script to compare values I've set as var1, var2, and var3 earlier in the script to the values in the userinputted column of four text files called Node1.txt, Node2.txt, Node3.txt, and Node4.txt and then replace the values in that userinputted column with either ttt or gcc,... (8 Replies)
Discussion started by: Eric1
8 Replies

8. Shell Programming and Scripting

Get extract and replace column with link in a column where it exists

hi i have sample data a,b,c,d,e,g h http://mysite.xyx z,b,d,f,e,s t http://123124# a,b,c,i,m,nothing d,i,j,e,w,nothing output expected is a,b,c,d,e,http://mysite.xyx z,b,d,f,e,http://123124# a,b,c,i,m,nothing d,i,j,e,w,nothing i can get only links using grep -o 'http.*' i... (8 Replies)
Discussion started by: zozoo
8 Replies

9. UNIX for Beginners Questions & Answers

Extract a column and multiple by 1000 and replace it on same file

Hi All, I need to extract a position in the file and multiple the value by 1000 and the replace it . Original 0010001200084701217637306521200000000000010010000000 ---> 000847 * 1000 0010012700086001213437404323000000000000001001000000 ---> 000860 * 1000... (2 Replies)
Discussion started by: arunkumar_mca
2 Replies

10. Shell Programming and Scripting

Bash script - How to update header of scripts in one pass - multiline search/replace

Hello. A find command return a list of file. For each fileReplace the content starting with the first "§" (of two) ending with last "ɸ" (of two), regardless of the content ( five lines ) by the following content (exactly) : §2019_08_23§ # # ... (8 Replies)
Discussion started by: jcdole
8 Replies
SDF(1)							User Contributed Perl Documentation						    SDF(1)

NAME
sdf - SDF Conversion Utility PURPOSE
sdf converts SDF files to other document formats. USAGE
usage : sdf [+alias] [-h[help]] [-o[out_ext]] [-l[log_ext]] [-O[out_dir]] [-2 format] [-D variable,..] [-n split_level] [-f flag,..] [-I include_path,..] [-p[prefilter]] [-a parameters] [-P[plang]] [-N[line_numbers]] [-g[get_report]] [-r report] [-L locale] [-k look] [-s style] [-S page_size] [-c config] [-u uses,..] [-H head_level] [-K head_look] [-d driver] [-y post_filter] [-z post_process,..] [-t target] [-v[verbose]] [-T trace_levels,..] [-w width] [-Y library_path,..] sdf_file ... purpose: convert an sdf file to another format version: 2.001 (SDF 2.001) The options are: Option Description -h display help on options -o output file extension -l log file extension -O output to input file's (or explicit) directory -2 the output format you want -D define variables -n heading level to autosplit into topics -f define flags (i.e. DOC_* variables) -I search path for include files, templates, etc. -p pre-filter input file from each argument -a parameters for the pre-filter -P pre-filter as a programming language -N number lines in pretty-printed source code -g pre-filter using sdfget with the report specified -r report to run on the SDF to transform it before formatting -L locale -k look library -s style of document -S page size for paper documents -c configuration library -u modules to use -H initial heading level -K heading look (H, A or P) -d format driver - default is expand -y filter to post-filter the output with -z list of post processing actions to do -t logical target format -v verbose mode -T debugging trace levels -w width for text-based outputs -Y search path for libraries The aliases are: Alias Description mc generate a MIMS chapter ms generate a MIMS spec mt generate a MIMS topic sdf2doc_fm generate Frame binary format via FrameMaker sdf2dvi_sgml generate DVI format via SGML sdf2fvo_fm generate FrameViewer format via FrameMaker sdf2hlp_mif generate Windows Help input files via MIF sdf2html_ generate a HTML document sdf2html_dir generate an SDF directory in HTML sdf2html_fm generate a HTML document via FrameMaker sdf2html_topicsgenerate HTML topics sdf2htx_ generate MIMS HTX format sdf2info_sgmlgenerate GNU info format via SGML sdf2latex_ generate LaTeX sdf2latex_podgenerate LaTeX format via POD sdf2latex_sgmlgenerate LaTeX format via SGML sdf2lyx_sgml generate a LyX file via SGML sdf2man_pod generate Man page format via POD sdf2mf6_ generate MIMS F6 help format sdf2mif_ generate Frame MIF format sdf2pdf_html generate PDF via HTML sdf2pdf_mif generate PostScript and PDF via FrameMaker sdf2pod_ generate POD format sdf2ps_fm generate PostScript via FrameMaker sdf2ps_fmbookgenerate PostScript via a FrameMaker book sdf2ps_html generate PostScript via HTML sdf2ps_pod generate PostScript via POD sdf2ps_sgml generate PostScript via SGML sdf2rtf_fm generate RTF format via FrameMaker sdf2rtf_mif generate RTF format via MIF sdf2rtf_sgml generate RTF format via SGML format sdf2sdf_expandgenerate expanded SDF sdf2sdf_raw generate raw SDF sdf2sgml_ generate SGML format sdf2txt_ generate plain text format sdf2txt_fm generate plain text format via FrameMaker sdf2txt_pod generate plain text format via POD DESCRIPTION
The -h option provides help. If it is specified without a parameter, a brief description of each option is displayed. To display the attributes for an option, specify the option letter as a parameter. By default, generated output goes to standard output. To direct output to a file per input file, use the -o option to specify an extension for output files. If the -o option is specified without a parameter, an extension of out is assumed. Likewise, error messages go to standard error by default. Use the -l option to create a log file per input file. If the -l option is specified without a parameter, an extension of log is assumed. By default, generated output and log files are created in the current directory. Use the -O option to specify an explicit output directory. If the -O option is specified without a parameter, the input file's directory is used. The -2 option is a convenient way of specifying the alias (collection of options) which generates the output you want. e.g. sdf -2html abc is equivalent to: sdf +sdf2html abc The -D option is used to define variables. These are typically used for controlling conditional text and substituting text which changes. The format used is: -Dvariable1=value1,variable2=value2 A flag is a shorthand way of specifying variables in the DOC family. i.e. -ftoc=3 is equivalent to -DDOC_TOC=3. The format of the -f option is: -fflag1=value1,flag2=value2 If a variable or flag is specified without a value, 1 is assumed. To generate HTML topics, the command is: sdf -2topics abc By default, this will create sub-topics for each heading already in a separate file. It will also autosplit level 1 headings into sub- topics. The -n option can be used to control which level headings are split at: o 1 autosplits on level 1 headings (the default) o 2 autosplits on level 2 headings o 3 autosplits on level 3 headings o 0 disables autosplitting. Include files are searched for in the current directory, then in the directories given by the -I option, then in the default library directory. By default, sdf is configured to prefilter files with certain extensions. For example: sdf mytable.tbl is equivalent to executing sdf on a file which only contains: !include "mytable.pl"; table The -p option can be used to explicitly prefilter files or to override the default prefilter used. If a parameter is not provided, the prefilter is assumed to be table. The -a option can be used to specify parameters for the prefilter. For example: sdf -aformat='15,75,10' mytable.tbl The -P option prefilters the input files as programming languages. The parameter is the language to use. If none is provided, the extension is assumed to be the language name. For example: sdf -P myapp.c is equivalent to executing sdf on a file which only contains: !include "myapp.c"; example; wide; lang='c' The -N option adds line numbers at the frequency given. The default frequency is 1. i.e. every line. The -g option prefilters the input files by executing sdfget using the default report (default.sdg). To change the report used, specify the report name as the parameter. If the report name doesn't include an extension, sdg is assumed. Note: sdfget searches for reports in the current directory, then in the stdlib directory within SDF's library directory. The -r option runs the nominated SDR report on each input before formatting. In other words, SDR reports provide a mechanism for: o analysing the SDF just before it would be formatted, and o replacing that SDF with the output of the report (also SDF) so that the final output is a nicely formatted report. For example, the sdf_dir report generates a directory (tree) of the components (files) included in an SDF document. Reports are stored in sdr files and are searched for using the usual rules. The -L option can be used to specify a locale. The default locale name is specified in sdf.ini. Locale naming follows POSIX conventions (i.e. language_country), so the locale name for American english is en_us. The information for each locale is stored in the locale directory, so you'll need to have to look in there to see what locales are available. (As the default locale can be set in sdf.ini, this isn't as ugly as it first sounds.) Note: At the moment, a locale file simply contains a list of language specific strings. Ultimately, it should be extended to support localisation of date and time formats. The -k option is used to specify a look. The default look library is specified in sdf.ini. The -s option can be used to specify a document style. Typical values are: o document - a technical document o memo - a memo o fax - a facsimile o minutes - minutes of a meeting. The -S option is used to specify the page size. Values supported include: Name Width Height Comment global 21.0cm 11.0in will fit on either A4 or letter A3 29.7cm 42.0cm A4 21.0cm 29.7cm A5 14.8cm 21.0cm B4 25.7cm 36.4cm B5 17.6cm 25.0cm letter 8.5in 11.0in legal 8.5in 14.0in tabloid 11.0in 17.0in Additional page sizes can be configured in sdf.ini. To specify a rotated version of a named page size, append an R. For example, A4R implies a width of 29.7cm and a height of 21cm. A custom page size can also be specified using the format: {{width}}x{{height}} where width and height are the respective sizes in points. The -c option is used to specify a configuration library. A list of modules to use can be specified via the -u option. The initial heading level to start on can be specified via the -H option. This is useful if you want to preview how a topic will be displayed without regenerating the complete document. If a topic begins with a level 1 heading (e.g. H1) and you wish to format it as a document (i.e. the level 1 text becomes the DOC_NAME for build_title), use the -H option with a value of 0. The look of headings can also be adjusted. By default, H-style headings are numbered, A-style headings are lettered and P-style headings are plain. To force a particular style for all headings, the -K option can be used. Sensible parameter values are H, A and P although other values may work depending on what paragraph styles are configured at your site. The -d option is used to specify the format driver. Values supported include: o expand - format as expanded text (the default) o mif - Maker Interchange Format o pod - Plain Old Documentation (as used by Perl). Additional drivers can be configured in sdf.ini. The -y option can to used to specify a post-filter. The -z option can be used to specify a list of post-processing actions you want to execute on each output file after it is generated. The actions supported include: o ps - generate PostScript o doc - generate a Frame (binary) file o fvo - generate a Frame View-Only file o txt - generate a text file o rtf - generate an RTF file o clean - delete the output file (must be last). Additional actions can be configured in sdf.ini. By convention, the generated files are given the same names as the action keywords. The -t option is used to specify the logical target format. If none is specified, the default is the first post processing action, if any. Otherwise, the default is the format driver name. The -v option enables verbose mode. This is useful for debugging problems related to post processing. In particular, post processing actions containing the pattern clean are skipped in verbose mode. You can also switch off the post processing messages by using a verbose value of -1. Values higher than 1 switch on additional trace messages as follows: o 2 - show how names of files and libraries are resolved 3 - show the directories searched for libraries 4 - show the directories searched for modules 5 - show the directories searched for normal files. The -T option can be used to switch on debug tracing. The parameter is a comma-separated list of name-value pairs where each name is a tracing group and each value is the level of tracing for that group. To get the trace output provided by the -v option, one can use the user group like this: sdf -Tuser=2 ... This is slightly different from the -v option in that intermediate files are not implicitly kept. Additional tracing groups will be added over time (probably one per output driver). The -w option is used to specify the width for text-based outputs. The -z, -D, -f and -I options are list options. i.e. multiple values can be separated by commas and/or the options can be supplied multiple times. EXAMPLES
Convert mydoc.sdf to a technical document in mif format, output is mydoc.mif: sdf -2mif mydoc.sdf Convert mydoc.sdf to online documentation in FrameViewer format, output is mydoc.fvo: sdf -2fvo mydoc.sdf Convert mydoc.sdf to online documentation in HTML, output is mydoc.html: sdf -2html mydoc.sdf The following command will build the reference documentation for a SDF module in HTML: sdf -2html abc.sdm LIMITATIONS AND FUTURE DIRECTIONS
Many of the default post processing (-z) actions only works on Unix as FrameMaker for Windows does not support batch conversion. Topics mode has several limitations: o only documents in the current directory can be converted o all sub-topics must also be in the current directory. perl v5.12.4 2011-11-09 SDF(1)
All times are GMT -4. The time now is 06:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy