LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-20-2015, 08:48 AM   #16
redone-22
LQ Newbie
 
Registered: Aug 2015
Posts: 11

Original Poster
Rep: Reputation: Disabled

how can i do to hide the hidden files?
 
Old 08-20-2015, 09:13 AM   #17
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by redone-22 View Post
hello habitual
your script is to dificult i need something easy
Iron sharpens iron, my friend.

Have fun!
 
Old 08-20-2015, 11:11 AM   #18
HMW
Member
 
Registered: Aug 2013
Location: Sweden
Distribution: Debian, Arch, Red Hat, CentOS
Posts: 773
Blog Entries: 3

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
Quote:
Originally Posted by redone-22 View Post
it gives me 4
I dare say that getting 4 is impossible.

First of all, there is no option -l (the letter L) in tail. You ought to get an error. But, I assume you mean the option -1 (the digit ONE).
If so, you produce only ONE line from the output. So, what happens when you do a line count on ONE line? You will get the result 1. Always.

Check this out:
Code:
$ cat lines.txt 
Line1
Line2
Line3
Line4
Ok, we have a simple file with four lines. Lets count them with wc:
Code:
$ wc -l lines.txt 
       4 lines.txt
Let's try your approach:
Code:
$ cat lines.txt | tail -1 | wc -l
       1
Please provide a sample of when you run the code, and how you can get 4 as a result, because something is very off.

Best regards,
HMW
 
Old 08-20-2015, 11:30 AM   #19
redone-22
LQ Newbie
 
Registered: Aug 2015
Posts: 11

Original Poster
Rep: Reputation: Disabled
#!/bin/bash

FOLDER_TOTAL=$(find ~/$1/* -maxdepth 0 -type d | wc -l)
FILE_TOTAL=$(find ~/$1/* -maxdepth 0 -type f -exec du -h {} + | tail -n 1000 | wc -l)
FOLDER_SIZE=$(find ~/$1/ -maxdepth 1 -exec du -ch {} + | tail -l | cut -d"/" -f4-8 | grep total | cut -d"t" -f1)

dir_info() {
echo "there are" $FOLDER_TOTAL "directories in the directory $1"
echo "there are" $FILE_TOTAL "files in the directory $1"
echo "the directory $1 is $FOLDER_SIZE great"
}

if [ -z "$1" ]
then
echo " Er zijn geen parameters beschikbaar"
else
until [ -z "$1" ]
do
case $1 in
* ) dir_info;;
esac
shift
done
fi

that is the code that i have written

Last edited by redone-22; 08-20-2015 at 11:33 AM.
 
Old 08-20-2015, 01:15 PM   #20
HMW
Member
 
Registered: Aug 2013
Location: Sweden
Distribution: Debian, Arch, Red Hat, CentOS
Posts: 773
Blog Entries: 3

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
Ok. First you post this:
Quote:
Originally Posted by redone-22
for the total number of file i have that : find -/$1/* -maxdepth 1 -type d -exec du -ch {} + | tail -l | wc -l
But now you post this:
Quote:
Originally Posted by redone-22
FILE_TOTAL=$(find ~/$1/* -maxdepth 0 -type f -exec du -h {} + | tail -n 1000 | wc -l)
But the same applies to what I wrote earlier. You pipe the output from tail into wc, and then count the lines, why!?! wc is just repeating the number of lines you specify with tail!
 
Old 08-20-2015, 01:21 PM   #21
redone-22
LQ Newbie
 
Registered: Aug 2015
Posts: 11

Original Poster
Rep: Reputation: Disabled
when i use tail -l some files disapear
 
Old 08-20-2015, 01:28 PM   #22
HMW
Member
 
Registered: Aug 2013
Location: Sweden
Distribution: Debian, Arch, Red Hat, CentOS
Posts: 773
Blog Entries: 3

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
Quote:
Originally Posted by redone-22 View Post
when i use tail -l some files disapear
Look, I am trying to help you out, but since you don't even read what I post, I think I am done here.

Best of luck!
HMW
 
1 members found this post helpful.
Old 08-20-2015, 01:48 PM   #23
redone-22
LQ Newbie
 
Registered: Aug 2015
Posts: 11

Original Poster
Rep: Reputation: Disabled
i have use wc to count how many directories there is in the directory
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Shell Scripting Part I: Getting started with bash scripting LXer Syndicated Linux News 0 04-29-2015 08:03 AM
LXer: Scripting the Linux desktop, Part 2: Scripting Nautilus LXer Syndicated Linux News 0 02-17-2011 04:02 AM
teaching shell scripting: cool scripting examples? fax8 Linux - General 1 04-20-2006 04:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:40 AM.

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