LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > CentOS
User Name
Password
CentOS This forum is for the discussion of CentOS Linux. Note: This forum does not have any official participation.

Notices


Reply
  Search this Thread
Old 02-20-2017, 09:22 AM   #1
robertkwild
Member
 
Registered: Feb 2015
Posts: 382

Rep: Reputation: Disabled
append writing to file aswell


hi all,

im doing this command and appending it to a text document it works great

find . -type f | wc -l >> oo.txt

it appears like this in the file

180416

how do i get it to write something in the beginning like

how many files = 180416

many thanks,

rob
 
Old 02-20-2017, 09:45 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
>> will do only append, you need to use sed, awk or another tool to write before.
Or you can first write the given text into that file and execute your command afterward.
 
Old 02-20-2017, 09:57 AM   #3
dijetlo
Senior Member
 
Registered: Jan 2009
Location: RHELtopia....
Distribution: Solaris 11.2/Slackware/RHEL/
Posts: 1,491
Blog Entries: 2

Rep: Reputation: Disabled
echo 'File Count =' $(find . -type f | wc -l) >> oo.txt

Which is effectively just what Pan said to do.

Last edited by dijetlo; 02-20-2017 at 10:11 AM. Reason: Kudos to Pan
 
Old 02-20-2017, 10:38 AM   #4
robertkwild
Member
 
Registered: Feb 2015
Posts: 382

Original Poster
Rep: Reputation: Disabled
thanks dijetlo
 
Old 02-20-2017, 12:23 PM   #5
dijetlo
Senior Member
 
Registered: Jan 2009
Location: RHELtopia....
Distribution: Solaris 11.2/Slackware/RHEL/
Posts: 1,491
Blog Entries: 2

Rep: Reputation: Disabled
No worries Rob, we all get by with a little help from our friends...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to append file to tar archive returns error “Cannot stat: No such file or dire Simon_zhu Linux - Newbie 3 06-11-2015 11:02 PM
Virus reformat windows aswell ssssaaaammmm66 Linux - Newbie 37 06-29-2009 06:46 AM
how to append contents of one file to another existing file amit_pansuria Programming 1 11-17-2008 10:01 AM
while loop creates a problem for a file opened in append mode for writing in PERL gaynut Programming 2 07-28-2008 07:26 PM
how to append columns form a column file in another file adam_blackice Programming 4 09-17-2007 11:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > CentOS

All times are GMT -5. The time now is 04:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration