0

I am not sure if i am on the right path or not, what i have so far is

#!/bin/sh

for filename in $*
do
if [ -d $filename ]
then
echo "some_text"
ls $filename
else
more $filename
fi
done

But it takes me to the next prompt, no output OR warnings

N.Ali
  • 61
  • 1
  • 9
  • 1
    Run your code through http://shellcheck.net/ and fix what it finds before asking questions here. – Charles Duffy Jul 07 '17 at 14:12
  • 1
    @anubhava, since "as an argument" is specified, I assume not. That said, `for filename in "$@"; do` or just `for filename; do` would certainly be more correct. – Charles Duffy Jul 07 '17 at 14:12
  • 1
    https://stackoverflow.com/questions/951336/how-to-debug-a-bash-script is also very, **very** pertinent here. – Charles Duffy Jul 07 '17 at 14:14
  • Right now, as this question is asked, we don't have enough information to debug it. We don't know how you're invoking your script (with what command line) -- which is important, since specific filenames can trigger bugs in this code. We don't know what it's actually doing when invoked, since there's no trace (`sh -x yourscript name1 name2`) included. And it's also broader than preferable, since the rules call for questions to be focused around *exactly one* bug, with code focused on reproducing only exactly that bug; this isn't focused around your bug, it's focused around your intent. – Charles Duffy Jul 07 '17 at 14:16

0 Answers0