wc -l on unix file

I have a unix script that I am check a data file record count. When I do the following I get the count and the file name assign to the variable. How can I get just the record count?

 TOTAL_RECORDS=`wc -l ${staging_dir}${curr_action_file}`

Thanks
TClevelAsked:
Who is Participating?
 
Nick UpsonConnect With a Mentor Principal Operations EngineerCommented:
newcount="$rowcount" | cut -f1 -d' '
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
wc -l ${staging_dir}${curr_action_file}
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
... but maybe I am missing something
0
Improve Your Query Performance Tuning

In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

 
TClevelAuthor Commented:
when I do wc -l ${staging_dir}${curr_action_file}
I get this 503883 /opt/envproc/nationwide/unprocessed/NWPOL20060609_d.TXT
I only what 503883

I just what the count in the variable not the file name
0
 
Nick UpsonPrincipal Operations EngineerCommented:
wc -l ${staging_dir}${curr_action_file} | cut -1
0
 
TClevelAuthor Commented:
I input the following and I get the error below

rowcount=`wc -l ${record_count_datafile}${FILE_FROM_NATIONWIDE} | cut -1`

cut: illegal option -- 1
usage: cut -b list [-n] [filename ...]
       cut -c list [filename ...]
       cut -f list [-d delim] [-s] [filename]
0
 
Nick UpsonPrincipal Operations EngineerCommented:
sorry, that is what comes of trying to type faster than brain

the end part should be      | cut -f1
0
 
TClevelAuthor Commented:
I am still getting
503883 /opt/envproc/nationwide/unprocessed/NWPOL20060609_d.TXT
when I use

rowcount=`wc -l ${record_count_datafile}${FILE_FROM_NATIONWIDE} | cut -f1`
echo $rowcount

Any other suggestion
0
 
Nick UpsonPrincipal Operations EngineerCommented:
this one I tested

| cut -f1 -d' '
0
 
TClevelAuthor Commented:
Now I get nothing when i echo $rowcount
0
 
Nick UpsonPrincipal Operations EngineerCommented:
[root@ueserv2 root]# rowcount=`wc -l /etc/passwd`
[root@ueserv2 root]# echo $rowcount | cut -f1 -d' '
35
0
 
TClevelAuthor Commented:
Yes it will display the count without the file name when I use echo but when I try to assign it to a variable and then display it I don't get anything. I need to assign the result to a variable to use later in the script.

NW2HOME=/opt/envproc/nationwide/
record_count_datafile=${NW2HOME}unprocessed/
newcount=$rowcount | cut -f1 -d' '

echo $newcount

I get nothing from the echo
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.