01-21-2012
Be careful with your expectations, as your results will actually be;
1 4
2 4
3 4
Even though the first two lines have nothing after the last "|" there will still be a count of 4 for each line - even for an empty field. You will need to manage that by either not adding the trailing "|" or checking for "relevant content" of each field. Something like, if a field = /^$/ then take 1 away from the value of NF.
If you have a consistent number of "|" then your NF will always be the same regardless of what is between them.
This User Gave Thanks to Android Control For This Post:
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi Chaps,
I'm trying to print the line number of a comma delimited file where the second field in the line is blank using AWK. Here is the code I have so far where am I going wrong. It is the last column in the file.
nawk -v x==0 'BEGIN {FS=",";OFS=","} x++ if ($2 == " ") print $x' bob.tst
... (3 Replies)
Discussion started by: rjsha1
3 Replies
2. Shell Programming and Scripting
Hi,
I have a huge file & I want to add a specific text in column. But I want to add this text from a specific line number to a specific line number & another text in to another range of line numbers.
To be more specific: lets say my file has 1000 lines & 4 Columns. I want to add text "Hello"... (2 Replies)
Discussion started by: Ezy
2 Replies
3. Shell Programming and Scripting
hi,
i have a file, i need to search for a string , if the line contains i need to print that line number and line ,
please help
thanks in advance
Satya (5 Replies)
Discussion started by: Satyak
5 Replies
4. Shell Programming and Scripting
Hello,
I am testing some data to get line number at cursor position 9 and found some problem, the code is below.Assume we got 3 attribute. At second attribute, there are some data(eg.A41/A6) missing like at the fourth and six line
11006 A41 1888
11006 ... (7 Replies)
Discussion started by: davidkhan
7 Replies
5. UNIX for Dummies Questions & Answers
Hello Everyone.
I am trying to display contains of a file from a specific line to a specific line(let say, from line number 3 to line number 5). For this I got the shell script as shown below:
if ; then
if ; then
tail +$1 $3 | head -n $2
else
... (5 Replies)
Discussion started by: grc
5 Replies
6. Shell Programming and Scripting
Hi,
I would like to know how do I print the line # in a script. My requirement is, I have a script which is about ~5000 lines long. If there are any errors happen I just exit. And I would like to add the line # of the script where the error happened.
Thanks, (6 Replies)
Discussion started by: suryaemlinux
6 Replies
7. Shell Programming and Scripting
I am looking for equivalent of following awk command in perl
# awk '{ print NF ":" $0 } ' junk1
8:VAH NIC_TYPE CONFIG SIZE_GB PILO KOM BHA_GRP DESCR
8:2 NIC6 cont 34 y n shal_orgrp /shal
8:4 NIC5 signa 52 n y shal_orgrp... (3 Replies)
Discussion started by: dynamax
3 Replies
8. Shell Programming and Scripting
Hello,
I have a question on how to find the line number of the first column that contains specific data. I know how to print all the line numbers of those columns, but haven't been able to figure out how to print only the first one that is found.
For example, if my data has four columns:
115... (3 Replies)
Discussion started by: user553
3 Replies
9. Shell Programming and Scripting
Hi
I want to use awk to match where field 3 contains a number within string - then print the line and just the number as a new field.
The source file is pipe delimited and looks something like
1|net|ABC Letr1|1530|||
1|net|EXP_1040 ABC|1121|||
1|net|EXP_TG1224|1122|||
1|net|R_North|1123|||... (5 Replies)
Discussion started by: Mudshark
5 Replies
10. Shell Programming and Scripting
datafile:
2017-03-24 10:26:22.098566|5|'No Route for Sndr:RETEK RMS 00040 /ZZ Appl:PF Func:PD Txn:832 Group Cntr:None ISA CntlNr:None Ver:003050 '|'2'|'PFI'|'-'|'EAI_ED_DeleteAll'|'EAI_ED'|NULL|NULL|NULL|139050594|ActivityLog|
2017-03-27 02:50:02.028706|5|'No Route for... (7 Replies)
Discussion started by: SkySmart
7 Replies
LEARN ABOUT DEBIAN
dist::zilla::app::command::new
Dist::Zilla::App::Command::new(3pm) User Contributed Perl Documentation Dist::Zilla::App::Command::new(3pm)
NAME
Dist::Zilla::App::Command::new - mint a new dist
VERSION
version 4.300020
SYNOPSIS
Creates a new Dist-Zilla based distribution under the current directory.
$ dzil new Main::Module::Name
There are two arguments, "-p" and "-P". "-P" specify the minting profile provider and "-p" - the profile name.
The default profile provider first looks in the ~/.dzil/profiles/$profile_name and then among standard profiles, shipped with Dist::Zilla.
For example:
$ dzil new -p work Corporate::Library
This command would instruct "dzil" to look in ~/.dzil/profiles/work for a profile.ini (or other "profile" config file). If no profile name
is given, "dzil" will look for the "default" profile. If no default directory exists, it will use a very simple configuration shipped with
Dist::Zilla.
$ dzil new -P Foo Corporate::Library
This command would instruct "dzil" to consult the Foo provider about the directory of 'default' profile.
AUTHOR
Ricardo SIGNES <rjbs@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by Ricardo SIGNES.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
perl v5.14.2 2012-06-21 Dist::Zilla::App::Command::new(3pm)