UNIX Query About wc -l output


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers UNIX Query About wc -l output
# 1  
Old 12-21-2012
UNIX Query About wc -l output

I was performing the wc -l operation in one data file the result is less when i was giving -nu on the view of the file.

while giving wc -l the count is 5023
after setting line numbers in view of file is giving 5024.
Can anyone help on this....

Last edited by abhii; 12-21-2012 at 04:18 AM..
# 2  
Old 12-21-2012
what is su -n ?

wc -l will count the newline character in a file
# 3  
Old 12-21-2012
Sorry for wrong command

it is -nu in view mode of file which will give us the line number for each line in the file. I hope i am right here..
# 4  
Old 12-21-2012
what is the last number of this command
Code:
cat -n filename | tail

# 5  
Old 12-21-2012
Thanks for reply

Code:
cat -n filename | tail

It is giving 5424.

Code:
 wc -l is giving 5423

I have one more doubt..
The first line itself is having lots of spaces.so in normal look it looks like second line which have no records..

will this can cuase the issue.

Last edited by vbe; 12-21-2012 at 05:19 AM.. Reason: code tags
# 6  
Old 12-21-2012
seems, your last line doesnt have the \n (new line character). So wc -l returns one less

Code:
 
tail -1 filename | od -c

execute the above command, and check whether you have \n in the output or not

---------- Post updated at 04:34 PM ---------- Previous update was at 04:32 PM ----------

Code:
 
$ echo "TEST" | wc -l
       1
$ echo -n "TEST" | wc -l
       0

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sql query output count

Hi Team, below sql rerturn 20 records, the result set i am going to assign to one variable and it showing count is 1. and i don't use count() in sql query... based on count, i need to fail the script. No_of_step=`echo ${g_count} | wc -l` function gf_count() { g_count=`sqlplus -s... (8 Replies)
Discussion started by: bmk123
8 Replies

2. Solaris

SQL QUERY to Table Output

Hi I am trying to run sql query from solaris in csh script and send the output to email. Below is my sql query select p.spid,se.program seprogram, se.machine, se.username, sq.sql_text,sq.retrows from v$process p inner join v$session se on p.addr = se.paddr inner join ( select... (2 Replies)
Discussion started by: tharmendran
2 Replies

3. Shell Programming and Scripting

I want query output to send on mail using table tag and output should be in table

#! /bin/ksh #] && . ./.profile 2>/dev/null if test -f '.profile'; then . ./.profile; fi; #. .profile LOG_DIR=/app/rpx/jobs/scripts/just/logs sendEmail() { pzCType="$1"; pzTitle="$2"; pzMsg="$3"; pzFrom="$4"; pzTo="$5"; pzFiles="$6"; pzReplyTo="$7" ( ... (21 Replies)
Discussion started by: ankit.mca.aaidu
21 Replies

4. UNIX for Dummies Questions & Answers

Maximum of the values from the output a query

Following is the output of a command ran inside the script: 2015-01-29-05-38-02 5 2015-01-29-05-38-02 5 2015-01-29-05-38-02 5 2015-01-29-05-38-02 5 2015-01-29-05-38-02 5 2015-01-29-05-38-03 5 2015-01-29-05-38-03 5 2015-01-29-05-38-03 5 2015-01-29-05-38-03 5 2015-01-29-05-38-03 5... (8 Replies)
Discussion started by: Devendra Hupri
8 Replies

5. Shell Programming and Scripting

SQL query in UNIX script - output in flat file

Hi, I never did this before... what I want to do is execute a SQL query from a unix script and redirect sql query's output to a flat file (comma separated one) without the header info (no column names). I would also want not to print the query's output to the screen. snapshot of my script:... (13 Replies)
Discussion started by: juzz4fun
13 Replies

6. Shell Programming and Scripting

Printing the output of a db2 query on to an unix file

I want to print the output of a db2 query, on to an unix file in a manner that the columns are separated by 'commas'. Please help me out..thanx in advance (1 Reply)
Discussion started by: prasan_ven
1 Replies

7. Shell Programming and Scripting

issue with the query output in unix

I am running a query with contains blank spaces in between in the output. But when I open and read the file in UNIX i am not able to cursor the balnk spaces instead it is moving like tabs. Please help suppose my query - Select ' '||text from tab1; the cursor should move to 1st and... (1 Reply)
Discussion started by: sbmk_design
1 Replies

8. Solaris

awk output query

Hi Everyone, When i issue command like ls -l | awk '/udtts/ {print $9}' =============================== I am getting output as udttsGEHLNAR.6864 udttsGEHLNAR.7921 udttsNARALAX.15415 udttsNARALAX.18016 But I want output after dot i.e like 6864 7921 15415 18016 (3 Replies)
Discussion started by: gehlnar
3 Replies

9. Shell Programming and Scripting

add the output of a query to a variable to be used in another query

I would like to use the result of a query in another query. How do I redirect/add the output to another variable? $result = odbc_exec($connect, $query); while ($row = odbc_fetch_array($result)) { echo $row,"\n"; } odbc_close($connect); ?> This will output hostnames: host1... (0 Replies)
Discussion started by: hazno
0 Replies

10. Shell Programming and Scripting

need help in reading a output of a sql query in unix script

i'm used a sql query in a unix script to get the information from table. but unable to extract the output which i need. Any help with logic will be greatly appreciated. my sql query provide output some thing like this - col1 col2 count ---- ---- ------ A B 10 c D 6 e... (8 Replies)
Discussion started by: pharos467
8 Replies
Login or Register to Ask a Question