Sponsored Content
Full Discussion: Just something simple
Top Forums Shell Programming and Scripting Just something simple Post 302081452 by aigles on Tuesday 25th of July 2006 11:23:21 AM
Old 07-25-2006
The following line is wrong :
Code:
do if [ -d $file ]

the correct syntax is
Code:
do
if [ -d $file ]

or
Code:
do ; if [ -d $file ]

Format your script, it will be more easy to read

Code:
#!/bin/sh
>shar
case $# in
   0) echo "1 Usage: enshar file [...] " >&2
      ;;
   *) for file
      do 
         if [ -d $file ]
         then echo "3 enshar: $file is a directory" >&2
         elif [ ! -f $file ]
         then echo "4 enshar: $file does'nt exist" >&2
         elif [ ! -r $file ]
         then echo "5 enshar: $file can't be read" >&2
         elif [ $file = !EnShAr! ]
         then echo "6 enshar: $file can't enshar" >&2
         else
              echo "cat > $file <<\!EnShAr!"
              cat $file
              echo "!EnShAr!"
              echo "set `cksum $file`"
              echo "cksum" $file`
              check=$1
              echo "test $1 = $check || echo $0: Bad cksum in $file >&2 " >> shar
              echo "cat > $file <<\!EnShAr!" >> shar
         fi
      done
      ;;
esac

 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Simple Q

I have installed Windows and Linux on the same machine but now it starts with windows all the time i need to get in and install Lilo but i don't know how i can get access to my Linux system, i have created an boot disk but it tries to start the installation all the time, i need to boot so i can get... (3 Replies)
Discussion started by: sajjan2
3 Replies

2. UNIX for Dummies Questions & Answers

Ok simple question for simple knowledge...

Ok what is BSD exactly? I know its a type of open source but what is it exactly? (1 Reply)
Discussion started by: Corrail
1 Replies

3. Shell Programming and Scripting

Simple if

Hi, I have a variable (x) that holds a file name - I need to write this: if x matches the patern *ABC* or the pattern DEF*T then action A else action B fi how to do that? Also, how can i change the or test to AND test? Thanks. (2 Replies)
Discussion started by: GNMIKE
2 Replies

4. UNIX for Advanced & Expert Users

simple one

echo echo ((zz=$ee+$ff+$aa)) echo $zz <==Problem==> ee= 12.5 ff = 20.6 aa = 10.5 The ouput of zz should be 43.6 BUT i am getting 42. So it means anything after the comma is not counted. Please help. (2 Replies)
Discussion started by: kekanap
2 Replies

5. Programming

Simple C question... Hopefully it's simple

Hello. I'm a complete newbie to C programming. I have a C program that wasn't written by me where I need to write some wrappers around it to automate and make it easier for a client to use. The problem is that the program accepts standard input to control the program... I'm hoping to find a simple... (6 Replies)
Discussion started by: Xeed
6 Replies

6. Shell Programming and Scripting

Simple to you not simple to me pattern matchin help

hey all, im new and my first question is: say i have a word "blahblah" how do i get and replace the last letter of the word with say k, so replace the h with a k. However you cant just replace the h it has to change the LAST LETTER of the word. Cheers In advance. :b: (0 Replies)
Discussion started by: aleks001
0 Replies

7. Shell Programming and Scripting

Help making simple perl or bash script to create a simple matrix

Hello all! This is my first post and I'm very new to programming. I would like help creating a simple perl or bash script that I will be using in my work as a junior bioinformatician. Essentially, I would like to take a tab-delimted or .csv text with 3 columns and write them to a "3D" matrix: ... (16 Replies)
Discussion started by: torchij
16 Replies

8. Red Hat

Syslog.conf: looking for a simple answer on a simple question

Cheers! In /etc/syslog.conf, if an error type is not specified, is it logged anywhere (most preferable is it logged to /var/log/messages) or not? To be more precise I am interested in error and critical level messages. At default these errors are not specified in syslog.conf, and I need to... (6 Replies)
Discussion started by: dr1zzt3r
6 Replies

9. UNIX for Dummies Questions & Answers

A Simple Clock, Well Maybe Not That Simple...

The attachment says it all really... It is a DEMO at a glance digital readout using the "date" command to make it useful... For a Mocbook Pro 13", OSX 10.7.5, but may well work on Linux variants too. Enjoy... #!/bin/bash # # Clock.sh # A bash DEMO to create a 6 x 7 character set... (4 Replies)
Discussion started by: wisecracker
4 Replies
CHECKBASHISMS(1)					      General Commands Manual						  CHECKBASHISMS(1)

NAME
checkbashisms - check for bashisms in /bin/sh scripts SYNOPSIS
checkbashisms script ... checkbashisms --help|--version DESCRIPTION
checkbashisms, based on one of the checks from the lintian system, performs basic checks on /bin/sh shell scripts for the possible presence of bashisms. It takes the names of the shell scripts on the command line, and outputs warnings if possible bashisms are detected. Note that the definition of a bashism in this context roughly equates to "a shell feature that is not required to be supported by POSIX"; this means that some issues flagged may be permitted under optional sections of POSIX, such as XSI or User Portability. In cases where POSIX and Debian Policy disagree, checkbashisms by default allows extensions permitted by Policy but may also provide options for stricter checking. OPTIONS
--help, -h Show a summary of options. --newline, -n Check for "echo -n" usage (non POSIX but required by Debian Policy 10.4.) --posix, -p Check for issues which are non POSIX but required to be supported by Debian Policy 10.4 (implies -n). --force, -f Force each script to be checked, even if it would normally not be (for instance, it has a bash or non POSIX shell shebang or appears to be a shell wrapper). --extra, -x Highlight lines which, whilst they do not contain bashisms, may be useful in determining whether a particular issue is a false posi- tive which may be ignored. For example, the use of "$BASH_ENV" may be preceded by checking whether "$BASH" is set. --version, -v Show version and copyright information. EXIT VALUES
The exit value will be 0 if no possible bashisms or other problems were detected. Otherwise it will be the sum of the following error val- ues: 1 A possible bashism was detected. 2 A file was skipped for some reason, for example, because it was unreadable or not found. The warning message will give details. SEE ALSO
lintian(1). AUTHOR
checkbashisms was originally written as a shell script by Yann Dirson <dirson@debian.org> and rewritten in Perl with many more features by Julian Gilbey <jdg@debian.org>. DEBIAN
Debian Utilities CHECKBASHISMS(1)
All times are GMT -4. The time now is 03:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy