Sponsored Content
Full Discussion: Basic bash, echo in loop for
Top Forums Shell Programming and Scripting Basic bash, echo in loop for Post 302745987 by Dabless on Tuesday 18th of December 2012 02:56:55 PM
Old 12-18-2012
Ok, I can send you the full code, the error you mentioned was function I din't need, I deleted it. I will send you a new screen shot with the error message. The comment are in french, and the echo that end with #trace is for debug
Code:
        

 #! /bin/bash
replog=/var/log
# Vérification du nombre d'entré
if [ $# -eq 0 ] ; then
        echo "Bon nombres de paramètre entré !" #A retiré       

        # Vérification si il y a bien des .gz
        ls -1 $replog/*.gz > /dev/null 2>&1
        if [ "$?" = "0" ]; then
                echo ".gz touvré !!" # Trace



  #Création du rep vieux-logs si besoin
                if [ ! -d $replog/vieux-logs ] ; then
                        echo "vieux log n'existe pas ! créon le !" #trace
                        mkdir $replog/vieux-logs
                else
                        echo "Vieux log existe ! Une étape de moin !" #trace
                fi

                #Vérification si mrnet.log existe
                if [ ! -f $replog/mrnet.log ] ; then
                        echo "Mrnet.log N'existe pas ! Créon le!" #trace
                        echo "Il ne faut pas oublier la fonction conteur !!!!" #trace
                        touch mrnet.log
                else
                        echo "Tout est baux, une étape de moins ! pas de mrnet.log a créé" #trace 
                fi


                #Boucle For
                for i  in  $replog/*.gz
                do
                        echo "Bravo, t'as comprit comment sa marche !" #trace
                        echo " $i "
                        `echo $i date +%d:%m:%Y` #this shit is fucked need help
                        `echo $datee  `>> $replog/mrnet.log
                        mv $i /var/log/vieux-logs
                done


                # Comparé 5k
                if [  `stat -c%s $replog/mrnet.log` -gt 5000  ]; then
                        echo "pipi caca pouet"
                else
                        echo "cacapipipouet"
                fi

        else
                echo "Pas de .gz trouvé :(" # TRace
        fi

else
        echo "Erreur Mauvais nombre de paramètre entré" #trace
fi

---------- Post updated at 02:56 PM ---------- Previous update was at 02:56 PM ----------

Image
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

A basic question of FOR loop

Hi, have a basic query. Please see the below code: list="one two three" for var in $list ; do echo $var list="nolist" Done Wht if I want to print only first/ last line in the list Eg one & three Regards er_ashu (3 Replies)
Discussion started by: er_ashu
3 Replies

2. Shell Programming and Scripting

Basic bash 'for loop' usage

Hi! I have a simple question about using a for loop. I'm trying to open up all the zip files in the currect directory with ark, but I am getting the error "bash: syntax error near unexpected token `for $i ; do ark $i ; done ; I looked in the info pages for bash, but I can't seem to figure... (2 Replies)
Discussion started by: Orange Stripes
2 Replies

3. Shell Programming and Scripting

really basic for loop question

sorry for being dumb here, but is there a way my for loop can take an entire line of a file into consideration instead of each word in a line... ill explain if i have a file like this # cat list serial: 23124 hostname: server1 and a script that does this # cat list.sh #!/bin/sh ... (6 Replies)
Discussion started by: hcclnoodles
6 Replies

4. Shell Programming and Scripting

Basic While loop won't exit...

Hi everyone - just like to say great forum...I've learned a lot off here but I just can't figure this one out...(first post) I'm writing a script to monitor a directory and email the latest modified file....(I realize there are better ways than I'm trying here...I don't like copying and pasting... (5 Replies)
Discussion started by: trevthefatty
5 Replies

5. Shell Programming and Scripting

Trying to run a basic for loop

OS : RHEL 6.1 Shell : Bash I had a similair post on this a few weeks back. But I didn't explain my requirements clearly then. Hence starting a new thread now. I have lots of files in /tmp/stage directory as show below. I want to loop through each files to run a command on each file. I... (8 Replies)
Discussion started by: kraljic
8 Replies

6. UNIX for Dummies Questions & Answers

Basic loop awk/shell script question..

Hi, Sorry if this is a newbie question. I guess you can use either awk or shell script for this sequence of operations, but knowing very little about either of them I'm not sure how I should try to write this. The basic objective is to copy certain files that are scattered all over my... (10 Replies)
Discussion started by: pc2001
10 Replies

7. Shell Programming and Scripting

Basic help improving for in loop

I'm obviously very new to this. I'm trying to write a simple for loop that will read the directory names in /Users and then copy a file into the same subdir in each user directory. I have this, and it works but it isn't great. #!/bin/bash HOMEDIRS=/Users/* for dirs in $HOMEDIRS; do if ];... (5 Replies)
Discussion started by: Heath_T
5 Replies

8. Shell Programming and Scripting

BASH - Need to echo for loop output to one line

I'm trying to echo the release version of some of our Linux servers. Typically I do these types of things by "catting" a text file with the host names, "ssh-ing" to the host and running my string. This is what I've written for i in `cat versions.txt` ; do echo $i ; ssh $i cat /etc/issue |... (5 Replies)
Discussion started by: lombardi4851
5 Replies

9. Shell Programming and Scripting

Basic FOR loop with break

Oracle Linux : 6.4/bash shell In the below I want to break out of the loop when it enters the 5th iteration. #!/bin/bash for i in 1 2 3 4 5 6 do echo "$i" if echo "Oh Nooo... i = $i. I need to stop the iteration and jump out of the loop" then break fi done But, it only... (3 Replies)
Discussion started by: John K
3 Replies

10. Shell Programming and Scripting

Echo with loop

Hello i have a file with this format: ip.txt content: 192.168.1.1/2020 192.136.1.2/2028 192.168.1.10/3047 .... need to create 1000 files and each files content, import data from ip.txt line (first file with first line data, second file with second line...etc) internal=yes internalip=... (14 Replies)
Discussion started by: nimafire
14 Replies
RBASH(1)						      General Commands Manual							  RBASH(1)

NAME
rbash - restricted bash, see bash(1) RESTRICTED SHELL
If bash is started with the name rbash, or the -r option is supplied at invocation, the shell becomes restricted. A restricted shell is used to set up an environment more controlled than the standard shell. It behaves identically to bash with the exception that the follow- ing are disallowed or not performed: o changing directories with cd o setting or unsetting the values of SHELL, PATH, ENV, or BASH_ENV o specifying command names containing / o specifying a filename containing a / as an argument to the . builtin command o specifying a filename containing a slash as an argument to the -p option to the hash builtin command o importing function definitions from the shell environment at startup o parsing the value of SHELLOPTS from the shell environment at startup o redirecting output using the >, >|, <>, >&, &>, and >> redirection operators o using the exec builtin command to replace the shell with another command o adding or deleting builtin commands with the -f and -d options to the enable builtin command o using the enable builtin command to enable disabled shell builtins o specifying the -p option to the command builtin command o turning off restricted mode with set +r or set +o restricted. These restrictions are enforced after any startup files are read. When a command that is found to be a shell script is executed, rbash turns off any restrictions in the shell spawned to execute the script. SEE ALSO
bash(1) GNU Bash-4.0 2004 Apr 20 RBASH(1)
All times are GMT -4. The time now is 05:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy