Hello !
I need some help with my simple bash script.
This script removes all files ( with name given in $1 ) in current dir and subdirectories .
The problem is with first loop in the script ( for file in * ; do ) .
When I run the sript in my home directory this script display sometimes(
probably special directories ) strange massage like :
" [: 31 : (d.) .png : undexpected operator " .
But When I write this loop like this : " for file in $( ls $dir ) " the sript
working perfectly ( but slow) .
How to remove the strange message ?
Paweł Łepko
Last edited by scotty_123; 03-11-2007 at 06:53 AM..
Reason: to hide code
To remove strange errors as you had mentioned
the script could be run as,
Well, that is not advisable,
could you please run the script with debug mode
to see why these errors do really occur !!!
( probably seems like missing parameters to test )
If the errors are fixed, then there is no need to run it as 2>/dev/null
I want to concatenate multiple files recursively from sub-directories intoone file in Linux.
I saved the following script as script.sh in $HOME/testing1 where I have several subdirectories and .txt files into them. I ran script.sh from the command prompt of $HOME/testing1 as ./script.sh. But it... (3 Replies)
Hi,
Question: how come the output is like that? Can explain to me abit. I am learning C.
Thanks!
#include <stdio.h>
#include <string.h>
void printit(char line_of_char, int index);
int main()
{
char line_of_char;
int index = -1;
strcpy(line_of_char, "This is a string.");
... (5 Replies)
Hi Guys,,
I tried to create a recursive function in unix.
The following is the code.
#/bin/sh
function(){
n=$1;
if ; then
out=1;
echo "inside if for 0";
else
out = `$n * function "$n-1"`;
echo "inside if for $n-1;
fi (3 Replies)
Hi, I'm trying to create a script that will display the contents of the users directories, but i'm confused about how to incorporate the shift properly.
The problem I'm getting with my script is that it goes throught the first couple of directories but then returns an error as it loses the... (10 Replies)
I want to halt a tail recursive function after certain validation. I want to come out of entire recursion without unwinding phase. How can i achieve that . The coding is done in C language. (5 Replies)
Hello, I'm scripting a newbie. I'm using KSH on HP-UX. I'm trying to write a script that will change a whole directory of file names into UPPER CASE.
I have the "convert to upper case" part of it working fine:
ls | while read filename; do
typeset -u uppercase
uppercase=${filename}
... (2 Replies)
I have a directory with its subdirectories and files. I want to change them all to read only. Say it is ~/test
chmod -R 444 ~/test
chmod: `/home/myname/test': permission denied
I do not understand. Do I have to have executable mode for a diirectory to access.
How can I change ~/test to... (5 Replies)
Hello every body. I am trying to find the factorial using the following code. But it is giving the syntax error. I tried very much but in vain. Thanks in advance for helping me
factorial()
{
if
then
y=`expr $1 - 1`
x=$(( $1 \* factorial $y ))... (6 Replies)
I am running a korn shell script which has a recursive function.
The script ran for 117 iterations and ended up with the following error
"recursion too deep".
what should be done to avert this?
Thanks in advance
Swamy
p.s. I am on UNIX MPRAS V4 (3 Replies)
I'm using the UNIX csh and i wish to use recursion to nav my way up (or down as it is) a given folder.
My little test script is called "r" and takes a folder as argv (or $1)
#!/bin/tcsh -f
set allFiles = `ls -A $argv`
cd $argv
while ($#allFiles)
if (-d... (1 Reply)