|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
hey am new to unix just wanted to know how to write a command that uses variable(s), the printf command and backquotes (") in order to print the correct number of files in a directory within a descriptive sentence. for example: 'your current directory (/home/abc123) has 12 files' . the command should run for any user.
i am not sure how to do this if any one can help it will be greatly appreatiated. thank you, sonya |
|
#2
|
|||
|
|||
|
Quote:
Hello sonya, try this: : printf "your current directory %s has %s plain files\n" $(pwd) $(find . -type f | wc -l) Copy and paste those two lines into the file scr.sh and then do the following: chmod +x scr.sh ./scr.sh This script will run under ksh or bash for any user that you allow. Read man chmod and some tutorial of shell programming. Have a fun ![]() |
|
#3
|
|||
|
|||
|
help please
This is not working i get an illegal variable name error is it to do with the plain file bit can someone help please?
Sonya |
|
#4
|
|||
|
|||
|
Quote:
Hello Sonya, I have tested my two lines on a computer. They are realy OK. Can you copy your error message and say exactly what you did? What Unix do you use? ![]() |
|
#5
|
|||
|
|||
|
Quote:
hello zlutovsky you are ASSUMING ksh or bash is running, every ASSUMPTION is bad (4 a programmer) try to do it working on EVERY env, it's simply the old way (+= costs nothing more) #!/bin/sh HERE=`pwd` FILES=`find $HERE -type f ¦ wc -l` # not really OK # maybe a 'grep -c .' is faster echo "your current directory $HERE has $FILES plain files"
__________________
working on Solaris[5-9], preferred languages french and C. |
|
#6
|
|||
|
|||
|
type of my shell
i am using cshell and i get an access denied error even though ive used chmod to change access to everyone even i dont undestand
|
|
#7
|
|||
|
|||
|
Quote:
Hello Sonya, I do not know the C shell. But I have learned many years ago,that the first line with single colon in it should cause the script to be executed by Bourne shell. And under Bourne shell it should run OK. So the script should be portable. Perhaps it is not so, I do not know. You could try to put instead of my first line the line #!"path to the Korn shell or Bourne again shell" i. e. #!/usr/bin/ksh or #!/bin/bash or whatever is correct in your Unix. Regards ![]() |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > UNIX Help > using 'printf' command and backquotes (") |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|