Sponsored Content
Full Discussion: awk printing question
Top Forums UNIX for Dummies Questions & Answers awk printing question Post 302708641 by pamu on Monday 1st of October 2012 11:59:33 PM
Old 10-02-2012
better way try this...

Code:
awk '{if($0 ~ /Dev Config/){a=1}else if($0 ~ /VDEV/ && $1 ~ /^[0-9]/){if(! X[a]){X[a]=$1;a++;if(a > max){max=a}}else{X[a]=X[a]" "$1;a++}}}END{  for(i=1;i<max;i++){print X[i]}}' file


Last edited by pamu; 10-02-2012 at 01:24 AM.. Reason: correction...
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

question about printing number of lines in a file

as the title, I had try use "wc -l test.txt" but it give me "<many spaces> 384 test.txt" but the result I want is just "384" could any person can help me that? Thx:( (5 Replies)
Discussion started by: a8111978
5 Replies

2. AIX

Stupid printing question

I am in the process of migrating software from HP-UX to AIX 5. On the HP box, instead of printing directly to the printer, we piped everything through a ksh script to set the printing parameters (such as landscape/portrait, 12.5 cpi, duplex, etc, etc) via the "-o" option. Since we move printers... (0 Replies)
Discussion started by: Highness
0 Replies

3. Shell Programming and Scripting

AWK printing

Hello, I am trying to write a formatted report into a file using .ksh script and awk. Here is the command I am trying to run echo "before awk" ${SRC_SCHEMA} echo | awk '{printf "%-20s", ${SRC_SCHEMA} }' >>$REPORT_SQL_NAME I get the following error before awk ADW awk: 0602-562 Field $()... (1 Reply)
Discussion started by: fastgoon
1 Replies

4. UNIX for Dummies Questions & Answers

Silly question on printing for loop in AWK

Hi, One silly question. I would like to add statement like below and append to a file. I used the below code; however, it does not work. Can anyone please tell me what mistakes I have made? awk ' { for (i=1;i<=563;i++) print i }'>>output.txt Thanks. -Jason (1 Reply)
Discussion started by: ahjiefreak
1 Replies

5. Shell Programming and Scripting

AWK Printing

i have a file and i want to print the second variable and add qoutes to it i do awk -F"|" '{print $2}' star.unl. i get the output xxxxxxx but i need the variable($2) to be in quotes.like "xxxxxxx" how do i do there please (3 Replies)
Discussion started by: tomjones
3 Replies

6. Shell Programming and Scripting

AWK printing

i have a file containing a line 123456 is it possible to use AWK to print it out to look like 1 2 3 4 5 6 (8 Replies)
Discussion started by: tomjones
8 Replies

7. Programming

A question about printing error message with perror

Dear all, I use perror in order to print an error message to the standar error. For example if a C program is called without its two necessary command line parameters then : if (argc != 3) { perror("use: ./myProgram <source file> <target file>\n"); return 1; } Now the... (2 Replies)
Discussion started by: dariyoosh
2 Replies

8. Shell Programming and Scripting

Awk printing help

Hallo, i have a file which looks like this: $1 $2 $3 Student1 55 Pass 55 Pass 35 Fail Student2 55 Pass 55 Pass 35 Fail i want that the $1 field... (3 Replies)
Discussion started by: saint2006
3 Replies

9. Shell Programming and Scripting

Printing using awk

Hi I am relatively new to awk so i am getting confused a lot I am in need of help ... I am trying to append coloumns to the end of line using AWK I tried using this command awk -F "," '{for(s=7;s<=217;s++);$s="0";}1' OFS=, sam_sri_out It is giving me an output like this...... (1 Reply)
Discussion started by: Sri3001
1 Replies

10. Shell Programming and Scripting

awk question for printing variables

Hi All, I have the following awk code where I am passing 4 variables to the program and I need to print them in the awk script. The variables are $start_month $start_date - $end_month $end_date. printf("\tFor More Information\n") > out_tmp1 printf("\tIf you have any questions about this... (6 Replies)
Discussion started by: nua7
6 Replies
Dev(3pm)						User Contributed Perl Documentation						  Dev(3pm)

NAME
PDL::Core::Dev - PDL development module DESCRIPTION
This module encapsulates most of the stuff useful for PDL development and is often used from within Makefile.PL's. SYNOPSIS
use PDL::Core::Dev; FUNCTIONS
isbigendian Is the machine big or little endian? print "Your machins is big endian. " if isbigendian(); returns 1 if the machine is big endian, 0 if little endian, or dies if neither. It uses the "byteorder" element of perl's %Config array. my $retval = isbigendian(); trylink a perl configure clone if (trylink 'libGL', '', 'char glBegin(); glBegin();', '-lGL') { $libs = '-lGLU -lGL'; $have_GL = 1; } else { $have_GL = 0; } $maybe = trylink 'libwhatever', $inc, $body, $libs, $cflags, {MakeMaker=>1, Hide=>0, Clean=>1}; Try to link some C-code making up the body of a function with a given set of library specifiers return 1 if successful, 0 otherwise trylink $infomsg, $include, $progbody, $libs [,$cflags,{OPTIONS}]; Takes 4 + 2 optional arguments. o an informational message to print (can be empty) o any commands to be included at the top of the generated C program (typically something like "#include "mylib.h"") o the body of the program (in function main) o library flags to use for linking. Preprocessing by MakeMaker should be performed as needed (see options and example). o compilation flags. For example, something like "-I/usr/local/lib". Optional argument. Empty if omitted. o OPTIONS MakeMaker Preprocess library strings in the way MakeMaker does things. This is advisable to ensure that your code will actually work after the link specs have been processed by MakeMaker. Hide Controls if linking output etc is hidden from the user or not. On by default except within the build of the PDL distribution where the config value set in perldl.conf prevails. Clean Remove temporary files. Enabled by default. You might want to switch it off during debugging. perl v5.14.2 2012-04-05 Dev(3pm)
All times are GMT -4. The time now is 05:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy