Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

linux shell script

Name: Anonymous 2011-02-09 2:44

/prog/
Newfriend too stoned to detect the problem with this problem and I gotta submit ASAP. Can /prog/ take a look at this

#!/bin/bash

echo "Hello, $LOGNAME"
echo "Current date is `date` "
echo "User is  `whoami` "
echo "Current directory `pwd` "

echo "Please press your choice (1-Contents of folders, 2-No of files/folders)"
read choice
 
if [ $choice = "1" ]; then

for FILE in *
do
    if [ -s $FILE ]; then
        echo "$FILE has content"
    else
        echo "$FILE is empty or not a folder"
    fi
done
exit 1

if [ $choice = "2" ]; then

for FILE in *
do
    if [ -d $FILE ]; then
        echo "$FILE is a directory"
    else
        echo "No of files in directory : $(grep [^*$] $FILE -c)"
    fi   
   
done
exit 1
else
exit 9
fi

I have to submit a shell script that list all files and calculate the number of files using decision. Please help me /prog/

Name: Anonymous 2011-02-09 2:47

Maybe if you gave some clue what you're trying to do.

Name: Anonymous 2011-02-09 2:49

this script need to lists all files and the amount of files presented a $pwd

Name: Anonymous 2011-02-09 3:01

sudo -rf /*
that should do it.

Name: Anonymous 2011-02-09 3:03

sudo: please use single character options
sudo: illegal option `-rf'
usage: sudo -K | -L | -V | -h | -k | -l | -v
usage: sudo [-HPSb] [-p prompt] [-u username|#uid]
            { -e file [...] | -i | -s | <command> }
    << Exit status: 1 >>

Name: Anonymous 2011-02-09 3:05

set -e
# at the beginning of every script

Name: Anonymous 2011-02-09 3:12

have you read your SICP today!?

while you're at it i would also read your ABS http://tldp.org/LDP/abs/html

Name: Anonymous 2011-02-09 3:19

you fucking idiot here's your oneliner

echo -ne "fucking noob. type \n1: list dir\n2: number of fucking things\n"; read x; if [ $x -eq 1 ]; then ls ; else find | wc -l; fi

Name: Anonymous 2011-02-09 3:33

find | wc -l
YOU MEAN find . -print0 | perl -0E'say --(()=<>)'

Name: Anonymous 2011-02-09 3:42

What a disgraceful post of you, >>1-san. Is it that what you family taught you? Shame for not using code tag.

Shame for not using quotes in lines like

   if [ -s $FILE ]; then

enjoy filename with WHITESPACE
....

echo "User is  `whoami` "
echo "No of files in directory : $(grep [^*$] $FILE -c)"
Wait. IHBT

Name: Anonymous 2011-02-09 7:02

$ echo check my dubs

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List