Search Results

Search: Posts Made By: techedipro
2,546
Posted By RudiC
Try also awk ' BEGIN {OFN[0] =...
Try also

awk '
BEGIN {OFN[0] = "temp_file"
OFN[1] = "abc_reject_pqr_a_1_yymmdd"
}

{print > OFN[substr($0,75,1)=="R"]
}
' file
2,546
Posted By jim mcnamara
This creates two output files, you can use the mv...
This creates two output files, you can use the mv command to rename them . I'm using short names.


awk ' substr($0, 75, 1)=="R" { print $0 > "has_r.rxt"; next}
{print $0} ' infilename >...
1,378
Posted By RudiC
Had you given the resp. info before, when...
Had you given the resp. info before, when requested to do so, the script had already had the necessary constructs. Try
awk -vPOS=31 -vLEN=3 ' # run awk, pass...
735
Posted By rbatte1
Hello techedipro, Which AIX version are you...
Hello techedipro,

Which AIX version are you running? It might make a difference.

Are these conditions to be AND-ed together or OR-ed together? Please be specific else we might go the wrong...
735
Posted By RudiC
Some sample data would help as the inverse...
Some sample data would help as the inverse complex pattern is beyond my imagination. What's your shell / version? Your files have leading dots? I guess <FiileName> is a typo?
5,585
Posted By Don Cragun
Does the following help? #!/usr/bin/ksh #...
Does the following help?
#!/usr/bin/ksh
# Usage: utlity_name Chunk_Size Filename...
# where: Chunk_Size is the number of lines to write in each output file.
#
# Filename is the filename (not...
5,585
Posted By Don Cragun
In addition to what RudiC said about passing...
In addition to what RudiC said about passing variables to awk. note also that the 2nd line in your script is unusual. One would usually expect either:
#!/usr/bin/ksh
awk...
5,585
Posted By RudiC
Why not awk '{print > sprintf ("%03d_%s",...
Why not
awk '{print > sprintf ("%03d_%s", 1+int((NR-1)/3), FILENAME)}' abc.txt, then?

Or even awk '{print > sprintf ("%03d_%s", (NR+2)/3, FILENAME)}' abc.txt
5,585
Posted By Don Cragun
So change: awk...
So change:
awk 'NR%3==1{x=sprintf("%03d_Test",++i);}{print > x}' abc.txtto:
awk 'NR%3==1{x=sprintf("%03d_%s",++i,FILENAME)}{print > x}' abc.txt
11,113
Posted By Chubler_XL
Here is a version that doesn't need gawk, in...
Here is a version that doesn't need gawk, in addition it produces "subcount.txt" which shows characters replaced and a replace count.


awk -v stamp=$(date +%Y%m%d%H%M%S) \
-v f="TOM PAT SAM...
2,798
Posted By Akshay Hegde
why don't you combine all in one like this awk...
why don't you combine all in one like this
awk '{s += gsub(/SIN\*[YN]/,"&")}END{if(s)print "<Totalcount><value>"s"</value></Totalcount>"}' file
11,113
Posted By Chubler_XL
-v stamp=$(date +%Y%m%d%H%M%S) assign stamp...
-v stamp=$(date +%Y%m%d%H%M%S) assign stamp variable with current date and time in YYYYMMDDhhmmss format - Note this is the time the process starts and all files produced in this session will have...
11,113
Posted By MadeInGermany
This is a true split: awk ' { if (/^H/)...
This is a true split:
awk '
{
if (/^H/) {header=$0}
else if (/^T/) {trailer=$0}
else {
fname=substr($0,34,3)".txt"
if (!(fname in A)) {A[fname]; print header > fname}
print...
Showing results 1 to 13 of 13

 
All times are GMT -4. The time now is 12:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy