Search Results

Search: Posts Made By: mechvijays
3,619
Posted By Akshay Hegde
Use this awk -F, '{f=sprintf("%s.txt",$3);...
Use this

awk -F, '{f=sprintf("%s.txt",$3); if(f in F){ print >>f }else { print >f ; F[f]} close(f) }' file

OR like this

awk '{f=sprintf("%s.txt",$3); if(f in F){ print >>f }else { print >f...
3,619
Posted By Akshay Hegde
Please rerun and post output.. change awk to...
Please rerun and post output.. change awk to /usr/xpg4/bin/awk or /usr/xpg6/bin/awk or nawk
3,619
Posted By drl
Hi. Similar to others, and run on Solaris...
Hi.

Similar to others, and run on Solaris specifically:
#!/usr/bin/env bash

# @(#) s1 Demonstrate sifting, collecting lines to files, awk.

# Utility functions: print-as-echo,...
3,619
Posted By Akshay Hegde
This will overwrite file everytime, did you try ?
This will overwrite file everytime, did you try ?
3,619
Posted By Makarand Dodmis
then like this .. will it?awk '{print > $3".txt";...
then like this .. will it?awk '{print > $3".txt"; close($3".txt")}' file
3,619
Posted By Akshay Hegde
if you are not closing you will get too many Too...
if you are not closing you will get too many Too many open files error with large input file.
3,619
Posted By Makarand Dodmis
tryawk '{print > $3".txt"}' filename
tryawk '{print > $3".txt"}' filename
3,619
Posted By Akshay Hegde
$ awk '{f=sprintf("%s.txt",$NF); if(f in F){...
$ awk '{f=sprintf("%s.txt",$NF); if(f in F){ print >>f }else { print >f ; F[f]} close(f) }' file
1,335
Posted By Don Cragun
Of course, if you have access to a 1993 or later...
Of course, if you have access to a 1993 or later version of the Korn shell, you can do this entirely with shell built-ins:
#!/bin/ksh
Detail_Amount_Sum=0
while read x
do ...
1,335
Posted By Scrutinizer
For a shell solution that should be faster, try...
For a shell solution that should be faster, try something like:
{ printf "scale=2; 0"
while read i; do
printf "+%s " "$i"
done
printf "\n"
} < IFs_temp1.txt | bc
1,335
Posted By Corona688
It is slow because you are running bc 9,000 times...
It is slow because you are running bc 9,000 times for 9,000 numbers. Transform the entire stream into something you can feed into bc directly instead -- one program instead of 9,000.

For example...
Showing results 1 to 11 of 11

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