Now showing the correct output

Hello

I am working on one script where I am trying to display all the directories which is inside the workspace but somehow it is giving me weird output and this is occurring only with one directory other also having the result.html file inside the directory.

 for i in `ls -1 | egrep -iv "hotfix|branch|TotalLinesOfCode"`;do echo $i;done
 
 Output
 removeScmSyncErrorLogFilejob
reportArtifactsPromotedToLayer
reportArtifactsPromotedToLayer\results.html
reportTHIDSPayerPromotedToPRE
reportTHIDSPayerPromotedToPROD
reportTHIDSPromotedToPRE
ReportTool

 

I don't want this show me the output in that format reportArtifactsPromotedToLayer\results.html.It should show the directory

reportArtifactsPromotedToLayer\results.html is filename, not dir+file. If list is from *nix filesystem. \ = backslash, not /.

for i in *hotfix* *branch* *TotalLinesOfCode*
do
       [ ! -d "$i" ] && continue  # not dir
      echo "$i"
done

I am very confused. The title of this thread is Now showing the correct output, but you seem to be saying that you your script is NOT showing the correct output???

The script you showed us cannot possibly produce the output you showed us. Without quotes around the operand in your echo command, it will never print a leading space in a filename (even if you actually have files named <space>Output and <space>removeScmSyncErrorLogFilejob where the <space> stands for a literal space character in your filenames).

Please answer the following questions to clarify what you are trying to do:

  1. What is your definition of a "workspace"? (Your ls command is going to list the contents of the current working directory; not all of the files in the file hierarchy rooted in the current working directory.)
  2. What operating system and shell are you using?
  3. What is the output from the command ls -1 in the directory where you ran your script?
  4. What output do you want?