Sponsored Content
Top Forums UNIX for Dummies Questions & Answers filnding the line in afile which has less number of '|''s Post 302592881 by pandeesh on Wednesday 25th of January 2012 07:49:56 AM
Old 01-25-2012
Actually if there are n "|"s then NF will be n+1.
So,if you have 192 "|"s then NF=193.
So convert your awk one liner accordingly.

---------- Post updated at 06:19 PM ---------- Previous update was at 05:43 PM ----------

hi,

I have tested just similar to your scenario:
My input file:
Code:
pandeeswaran@ubuntu:~/training$ cat testfile
aghagh|hdjhdkhak|hdjhadja|hdsjhdj|hhjdh|hsjdhsk
gdhdg|hdjah|sklksl
hshsjh|hdjhdjh|dsjhdjsh|hjsdhs|hdjshdjs|ssk
jdkjkd|jskjks
jkj|jksjk

In the above data, i want only the lines which has less than 5 "|"symbols and the below ask does that:
Code:
pandeeswaran@ubuntu:~/training$ nawk -F"|" 'NF<6{print}' testfile
gdhdg|hdjah|sklksl
jdkjkd|jskjks
jkj|jksjk

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Appending line number to each line and getting total number of lines

Hello, I need help in appending the line number of each line to the file and also to get the total number of lines. Can somebody please help me. I have a file say: abc def ccc ddd ffff The output should be: Instance1=abc Instance2=def Instance3=ccc Instance4=ddd Instance5=ffff ... (2 Replies)
Discussion started by: chiru_h
2 Replies

2. Shell Programming and Scripting

Adding a columnfrom a specifit line number to a specific line number

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

how many times a word occur in afile

i want a shell script program for how many times a word occur in a file. i need not the line number but i want the counts of the particular word for eg:- hai how r u.. i am from andhra pradesh.. i am from tenali.i need this answer.i need it urgently.. i hope u will answer this ... ... (9 Replies)
Discussion started by: madhu.it
9 Replies

4. Shell Programming and Scripting

how to get the data from line number 1 to line number 100 of a file

Hi Everybody, I am trying to write a script that will get some perticuler data from a file and redirect to a file. My Question is, I have a Very huge file,In that file I have my required data is started from 25th line and it will ends in 100th line. I know the line numbers, I need to get all... (9 Replies)
Discussion started by: Anji
9 Replies

5. Shell Programming and Scripting

delete lines containing a specific word in afile

Hi, Please suggest how to write a shell script which delets all the lines containing the word unix in the files supplied as argument in the shell. (4 Replies)
Discussion started by: sireesha9
4 Replies

6. UNIX for Dummies Questions & Answers

How to read contents of a file from a given line number upto line number again specified by user

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

7. Shell Programming and Scripting

Write $line number into textfile and read from line number

Hello everyone, I don't really know anything about scripting, but I have to manage to make this script, out of necessity. #!/bin/bash while read -r line; do #I'm reading from a big wordlist instructions using $line done Is there a way to automatically write the $line number the script... (4 Replies)
Discussion started by: bobylapointe
4 Replies

8. UNIX for Dummies Questions & Answers

how to join all lines in afile in unix

Hi, I have a unix file which has many lines, i need to join all the lines to single line. Eg: myfile.txt contains: a 123 45fg try and i need the output as : a 123 45fg try Please help me on this. Thanks! (2 Replies)
Discussion started by: RP09
2 Replies

9. Shell Programming and Scripting

Cut from specific line number to a line number

Hi All, I've a file like this.. Sheet1 a,1 a,2 a,3 a,4 a,5 Sheet2 a,6 a,7 a,8 a,9 a,10 Sheet3 a,11 a,12 a,13 (7 Replies)
Discussion started by: manab86
7 Replies

10. Shell Programming and Scripting

sed command to replace a line at a specific line number with some other line

my requirement is, consider a file output cat output blah sdjfhjkd jsdfhjksdh sdfs 23423 sdfsdf sdf"sdfsdf"sdfsdf"""""dsf hellow there this doesnt look good et cetc etc etcetera i want to replace a line of line number 4 ("this doesnt look good") with some other line ... (3 Replies)
Discussion started by: vivek d r
3 Replies
FANN_TRAIN_ON_FILE(3)							 1						     FANN_TRAIN_ON_FILE(3)

fann_train_on_file - Trains on an entire dataset, which is read from file, for a period of time

SYNOPSIS
bool fann_train_on_file (resource $ann, string $filename, int $max_epochs, int $epochs_between_reports, float $desired_error) DESCRIPTION
Trains on an entire dataset, which is read from file, for a period of time. This training uses the training algorithm chosen by fann_set_training_algorithm(3) and the parameters set for these training algorithms. PARAMETERS
o $ann -Neural network resource. o $filename - The file containing train data o $max_epochs - The maximum number of epochs the training should continue o $epochs_between_reports - The number of epochs between calling a user function. A value of zero means that user function is not called. o $desired_error - The desired fann_get_MSE(3) or fann_get_bit_fail(3), depending on the stop function chosen by fann_set_train_stop_function(3) RETURN VALUES
Returns TRUE on success, or FALSE otherwise. SEE ALSO
fann_train_on_data(3), fann_train_epoch(3), fann_get_bit_fail(3), fann_get_MSE(3), fann_set_train_stop_function(3), fann_set_training_algo- rithm(3), fann_set_callback(3). PHP Documentation Group FANN_TRAIN_ON_FILE(3)
All times are GMT -4. The time now is 09:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy