Sponsored Content
Top Forums Shell Programming and Scripting How print evencolumns using awk ? Post 302998591 by RavinderSingh13 on Sunday 4th of June 2017 02:42:46 PM
Old 06-04-2017
Hello quincyjones,

Hard to believe that it uses 60 GB of memory, it's really a plenty of it?

Since I don't have that much size of Input_file so solution will be on assumption or a try only. In my previous solution I have put 1 condition which will check if variable i's value is equal to value of NF(Number of fields) or not, which was off course to NOT to have a TAB at last of line, since we are talking in terms of performance here then you could try to remove than condition and let me know, if you are ok with a TAB at last of line then let it be same code.
Code:
awk '{gsub(/\r/,"");printf("%s\t",$1);for(i=2;i<=NF;i+=2){printf("%s\t",$i)};print ""}'   Input_file

If you want to remove TAB at last of each line then you could add | awk '{sub(/[[:space:]]+$/,"");print}' after Input_file in above code I think that should be more faster than checking conditions in each fields etc. Kindly try it out and let me know how it goes then.

Thanks,
R. Singh
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How do I get awk to print a " in it's print part?

The line is simple, use " '{ print $1"]"$2"\"$3THE " NEEDS TO GO HERE$4 }' I've tried \", "\, ^" and '"" but none of it works. What am I missing? Putting in the [ between $1 and $2 works fine, I just need to do the same with a ". Thanks. (2 Replies)
Discussion started by: LordJezo
2 Replies

2. Shell Programming and Scripting

awk and print

Hi What is the correct syntax for use a variable value within a print sentence : Example: VAR1=$1 VAR2=$2 ls -l $VAR2/*.LOG | grep -v $VAR1 | nawk -F " " '{ print "mv "$9 " /backup/BACKUP/backup_db_type/$VAR1_arch/."}' > move_arch_des.sh Is this case i need to print $VAR1 within... (3 Replies)
Discussion started by: osymad
3 Replies

3. Shell Programming and Scripting

Awk and print help

Hello I have a log file like so 2009-01-15 17:55:06 H=host-216-153-217-114.spr.choiceone.net :30675 I=:25 F=<> rejected RCPT <feast@test.co.uk>: DNSBL listed at sbl-xbl.spamhaus.org What I am trying to do is be able to print x amount of columns after a certain part of the line say F= grep... (1 Reply)
Discussion started by: casseyjon
1 Replies

4. Shell Programming and Scripting

Awk problem: How to express the single quote(') by using awk print function

Actually I got a list of file end with *.txt I want to use the same command apply to all the *.txt Thus I try to find out the fastest way to write those same command in a script and then want to let them run automatics. For example: I got the file below: file1.txt file2.txt file3.txt... (4 Replies)
Discussion started by: patrick87
4 Replies

5. Shell Programming and Scripting

print through AWK

Hi friends I need one help from you . I want to print name='JACK' through . how can i make it . awk '{print "name=jack"}' it ll print name=JACK (6 Replies)
Discussion started by: imipsita.rath
6 Replies

6. Shell Programming and Scripting

Print using awk

Hi.. I have two files. contents of the files are as below. header1.dat ------------- This is a header record. header2.dat ------------- This is a header record. Date:2011-01-05 I am executing the below scripts. HEADER1=`cat header1.dat` HEADER2=`cat header2.dat` awk 'BEGIN... (2 Replies)
Discussion started by: 46019
2 Replies

7. UNIX for Advanced & Expert Users

awk print help

In this: $ awk '{ print "var is", var }' var=TEST file1 What does the print part do? { print "var is", var } (4 Replies)
Discussion started by: cokedude
4 Replies

8. Shell Programming and Scripting

AWK print AWK command

awk '{print "awk '{sub(/pdb_00/,"pdb_"$0"_00"); print}' pdb_"$0"_00.namd > tempo"; print "mv tempo pdb_"$0"_00.namd"}' datA2.dat > copy_script2.bash This works when trying to print 'sed etc. etc' but if I switch to using AWK to print a set of AWK commands it doesn't work... e.g. this... (3 Replies)
Discussion started by: chrisjorg
3 Replies

9. Shell Programming and Scripting

awk Print New Column For Every Two Lines and Match On Multiple Column Values to print another column

Hi, My input files is like this axis1 0 1 10 axis2 0 1 5 axis1 1 2 -4 axis2 2 3 -3 axis1 3 4 5 axis2 3 4 -1 axis1 4 5 -6 axis2 4 5 1 Now, these are my following tasks 1. Print a first column for every two rows that has the same value followed by a string. 2. Match on the... (3 Replies)
Discussion started by: jacobs.smith
3 Replies

10. Shell Programming and Scripting

Awk: Print count for column in a file using awk

Hi, I have the following input in a file & need output as mentioned below(need counter of every occurance of field which is to be increased by 1). Input: 919143110065 919143110065 919143110052 918648846132 919143110012 918648873782 919143110152 919143110152 919143110152... (2 Replies)
Discussion started by: siramitsharma
2 Replies
pthread_condattr_init(3T)												 pthread_condattr_init(3T)

NAME
pthread_condattr_init(), pthread_condattr_destroy() - initialize or destroy a condition variable attributes object. SYNOPSIS
PARAMETERS
attr Pointer to the condition variable attributes object to be initialized or destroyed. DESCRIPTION
initializes the condition variable attributes object attr with the default values for all attributes. The attributes object describes a condition variable in detail and is passed to the condition variable initialization function. When a condition variable attributes object is used to initialize a condition variable, the values of the individual attributes determine the characteristics of the new condition variable. Attributes objects act like additional parameters to object initialization. A single attributes object can be used in multiple calls to the function When a condition variable is initialized with an attributes object, the attributes are, in effect, copied into the condition variable. Consequently, any change to the attributes object will not affect any previously initialized condition variables. Once all condition vari- ables needing a specific attributes object have been initialized, the attributes object is no longer needed. The condition variable attributes and their default values are: The default value is If an initialized condition variable attributes object is reinitialized, undefined behavior results. destroys the condition variable attributes object attr. The destroyed condition variable attributes object ceases to exist and its resources are reclaimed. Using attr after it has been destroyed results in undefined behavior. A destroyed condition variable attributes object can be reinitialized using the function Condition variables that have been already initialized using this attributes object are not affected by the destruction of the condition variable attributes object. RETURN VALUE
Upon successful completion, and return zero. Otherwise, an error number is returned to indicate the error (the variable is not set). ERRORS
If any of the following occur, the function returns the corresponding error number: [ENOMEM] There is insufficient memory available in which to initialize the condition variable attributes object. [EINVAL] attr is not a valid condition variable attributes object. For each of the following conditions, if the condition is detected, the function returns the corresponding error number: [EINVAL] attr is not a valid condition variable attributes object. AUTHOR
and were derived from the IEEE POSIX P1003.1c standard. SEE ALSO
pthread_create(3T), pthread_condattr_getpshared(3T), pthread_cond_init(3T). STANDARDS CONFORMANCE
Pthread Library pthread_condattr_init(3T)
All times are GMT -4. The time now is 05:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy