Now showing the correct output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Now showing the correct output
# 1  
Old 01-27-2015
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.

Code:
 for i in `ls -1 | egrep -iv "hotfix|branch|TotalLinesOfCode"`;do echo $i;done

Code:
 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

Last edited by rbatte1; 01-28-2015 at 08:25 AM..
# 2  
Old 01-28-2015
reportArtifactsPromotedToLayer\results.html is filename, not dir+file. If list is from *nix filesystem. \ = backslash, not /.
Code:
for i in *hotfix* *branch* *TotalLinesOfCode*
do
       [ ! -d "$i" ] && continue  # not dir
      echo "$i"
done

# 3  
Old 01-28-2015
Quote:
Originally Posted by anuragpgtgerman
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.

Code:
 
 for i in `ls -1 | egrep -iv "hotfix|branch|TotalLinesOfCode"`;do echo $i;done

Code:
 
 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
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?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Pgrep not showing desired output

I am searching for a process that should be up and running. Im using the following command ps -ef | grep elasticsearch to get elastic+ 1673 1 0 Jan29 ? 05:08:56 /bin/java -Xms4g -Xmx4g -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC... (1 Reply)
Discussion started by: Junaid Subhani
1 Replies

2. Shell Programming and Scripting

Script showing incorrect output

Hello scripting geeks, I am new to scripting and facing some issues in writing the logic of the script. Request your kind help here Actually when i run a command i get o/p as below o/p : 0x0000 0x0000 0x0000 0x0000 0x0000 0x0000 these are hex values i guess...now i want to... (15 Replies)
Discussion started by: kulvant29
15 Replies

3. UNIX for Dummies Questions & Answers

Command showing no output!

Hi Folks, I have a situation here, where no command is giving any output, and it's not even showing any error message also. What could be the reason? (3 Replies)
Discussion started by: nixhead
3 Replies

4. Solaris

Showing strange size in df output

Hi, This is Solaris-10 box and in few of file-system (root file-system of non global zones), usage/available is not showing correct size. I am not able to figure out, what is eating up this space. Global Server - bdrpod01 Non Global zone - bdrpod01-zputq01 root@bdrpod01:/root# df -h... (2 Replies)
Discussion started by: solaris_1977
2 Replies

5. Shell Programming and Scripting

Not showing the correct string...

Scripting GURU, I have written a ksh script to get a number from a file and attempting to input the number into the sendsms output script.. But i am finding that ONCALL_NUMBER is showing as $ONCALL_NUMBER as the output for the TO:$ONCALL_NUMBER@sms.info.com message and not as... (3 Replies)
Discussion started by: Junes
3 Replies

6. UNIX for Dummies Questions & Answers

HELP! showing output as a ratio in uniq

Hi, I have the following file called addresses, (it is a large file i have only copy and pasted few of the data below) and I am wanting to write a command so it will Find the ratio of mobile (07....) to land line (01....) telephone numbers? then find the most popular first name and list the... (1 Reply)
Discussion started by: tina_2010
1 Replies

7. Shell Programming and Scripting

diff output is it correct??

I'm asking for explanation about the output of the diff format when i compare the two files f1 and f2: root@host1 # cat f1 205226 205237 205250 205255 205262 205274 205307 205403 205464 205477 205500 205520 205626 205759 205766 205776 (2 Replies)
Discussion started by: ahmad.zuhd
2 Replies

8. Shell Programming and Scripting

AWK not giving me correct output.

i have a line like this in my script IP=`get_IP <hostname> | awk '{ print $1 }' echo $IP the problem is get_IP <hostname> returns data formated as follows: ip 1.1.1.1 name server_name the code above returns 1.1.1.1 server_name and i just need the 1.1.1.1 I have tried to add "|... (5 Replies)
Discussion started by: mcdef
5 Replies

9. Linux

Process start time not showing correct time

Process start time is not showing the correct time: I had started a process on Jun 17th at 23:30:00. Next day morning when I run the command "ps -ef | grep mq", the process is showing the start date of Jun 17th but the start time is 00:16:41 Day/Date is setup correctly on the server. It... (2 Replies)
Discussion started by: hemangjani
2 Replies

10. UNIX for Dummies Questions & Answers

counting lines and showing the output

First time poster - I have a huge file and i want to sort and compress it to something more readable Ex: FUTNCA01-SL1 DMT8a4 5 3 FUTNCA01-SL1 DMT8a4 5 9 FUTNCA01-SL1 DMT8a4 5 21 FUTNCA01-SL1 DMT8a4 5 22 FUTNCA01-SL1 DMT8a4 5 23 FUTNCA01-SL1 DMT8a4 5 24 FUTNCA01-SL1 DMT8a4 6 2... (13 Replies)
Discussion started by: jjoves
13 Replies
Login or Register to Ask a Question