Visit Our UNIX and Linux User Community


How to remove space in between the result


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to remove space in between the result
# 1  
Old 08-10-2009
How to remove space in between the result

Hi All,

How do i remove the spaces in between, the outputted result: my output is like below and i dont want spaces between them, how do i do that. I am enclosing the peice of code that does that:-


Code:
 if [ $? -eq 0 ]; then
 $ECHO "The Path is:" $OFFERING_FILE_PATH/$z
 $ECHO $Z
 else
 $ECHO ""
 fi

##############################################
Output:-


Code:
Words to be searched: CCRCWebServerINSTALLDIR
The Path is: /home/administrator/testfix/install/cc.offering/com.ibm.rational.cl
earcase.assembly.assembly
<includedShareableEntity id="CCRCWebServerINSTALLDIR">














Words to be searched: ClearCaseAdministrationTools-CINSTALLDIR
The Path is: /home/administrator/testfix/install/cc.offering/com.ibm.rational.cl
earcase.assembly.assembly
<includedShareableEntity id="ClearCaseAdministrationTools-CINSTALLDIR">














Words to be searched: ClearCaseAdministrationTools-ent-CINSTALLDIR
The Path is: /home/administrator/testfix/install/cc.offering/com.ibm.rational.cl
earcase.assembly.assembly
<includedShareableEntity id="ClearCaseAdministrationTools-ent-CINSTALLDIR">

# 2  
Old 08-10-2009
It looks like that is from the contents of $Z. How does $Z get defined?
# 3  
Old 08-10-2009
Hi Peterro,

The Z variable is defined as:-
Z=`find $OFFERING_FILE_PATH/$z | xargs grep $i`

Thanks for coming to help again

-Adi
# 4  
Old 08-10-2009
Ok, what is $i? Is this script really large, or would it be appropriate to post all of it here? What I'm trying to get at is that if you can just gather the data you want, the output won't look so bad. From what I see so far, it looks like your getting too much of something (blank lines) when defining variables.
# 5  
Old 08-10-2009
why do u need the below code from ur code???

Code:
 else
 $ECHO ""

# 6  
Old 08-10-2009
Sure,
There is no problem posting it here:-

Code:
#!/bin/sh

ECHO=/bin/echo
CAT=/bin/cat
LS=/bin/ls
AWK=/bin/awk
GREP=/bin/grep

FIX_XML_PATH=/home/administrator/testfix/fix
FIX_FILE=`$LS $FIX_XML_PATH | $GREP xml`
OFFERING_FILE_PATH=/home/administrator/testfix/install/*.offering
OFFERING_FILE=`$LS $OFFERING_FILE_PATH | $GREP assembly`

Y=`$CAT $FIX_XML_PATH/$FIX_FILE | $GREP id | $AWK '{if($2 ~ /id=/) pri
nt $2}' | $AWK -F"'" '$1 == "id=" {print $2}'`

for i in $Y
do
 $ECHO "Words to be searched:" $i
 for z in $OFFERING_FILE
  do
   #$ECHO "The Path is:" $OFFERING_FILE_PATH/$z
   #Z=`find $OFFERING_FILE_PATH/$z -exec grep  $i {} \;`
   Z=`find $OFFERING_FILE_PATH/$z | xargs grep $i`

   if [ $? -eq 0 ]; then
   $ECHO "The Path is:" $OFFERING_FILE_PATH/$z
   $ECHO $Z
   else
   $ECHO ""
   fi

  done

# 7  
Old 08-10-2009
Yup, I think malcomex999 has the answer. Change the
Code:
echo ""

to
Code:
echo "this line intentionally left blank"

and see what you get.

Previous Thread | Next Thread
Test Your Knowledge in Computers #437
Difficulty: Medium
Vue.js is a free, proprietary JavaScript framework.
True or False?

10 More Discussions You Might Find Interesting

1. Programming

Python 3 remove the space after the last /

using python 3 when i run this code to get the urls i get a space in the url how do i remove the space after the last / thanks # Import libraries import requests from bs4 import BeautifulSoup # Connect to the URL page = requests.get('https://www.meihoski.co.jp/movie/') soup... (3 Replies)
Discussion started by: bob123
3 Replies

2. Shell Programming and Scripting

Remove a character and assign result to a variable

I am reading lines from a file that contain a number sign (#) before a three or four digit number: #1043 #677 I can remove the '#' and get just the number. However, I then want to assign that number to a variable and use it as part of a path further on in my program: /mydir/10/1043 for... (5 Replies)
Discussion started by: KathyB148
5 Replies

3. Shell Programming and Scripting

Remove ./ from result when i do find

Hi All, When i do find command i am getting result which append ./ before the file name. For example if i am trying to search aaa.txt in current directory i am using find like this: $ find . -name aaa.txt result: ./aaa.txt Now i want to remove "./" from the file name. Can some body... (5 Replies)
Discussion started by: VasuKukkapalli
5 Replies

4. UNIX for Advanced & Expert Users

Need to remove leading space from awk statement space from calculation

I created a awk state to calculate the number of success however when the query runs it has a leading zero. Any ideas on how to remove the leading zero from the calculation? Here is my query: cat myfile.log | grep | awk '{print $2,$3,$7,$11,$15,$19,$23,$27,$31,$35($19/$15*100)}' 02:00:00... (1 Reply)
Discussion started by: bizomb
1 Replies

5. Shell Programming and Scripting

Remove trailing space

Hi I am trying to remove trailing space from a string. value=${value%% } It is not working. What might be the issue with the above snippet. (7 Replies)
Discussion started by: munna_dude
7 Replies

6. Shell Programming and Scripting

remove space

File A.txt A005 -119.5 -119.5 -100.5 A006 -120.5 -119.5 -119.3 A008 0 0 0 Output A005 -119.5 -119.5 -100.5 A006 -120.5 ... (1 Reply)
Discussion started by: asavaliya
1 Replies

7. Shell Programming and Scripting

Remove last space in a string?

I have a customer file now and would like to separate the names into two cells in a spreadsheet. Here is my data as an example: SHAWN R KEEGAN shawn r scroggin Shawn Regan Shawn Reilly The first two have the middle initial so I'd like to include them in the "first name" field and the last... (11 Replies)
Discussion started by: Grassy
11 Replies

8. Shell Programming and Scripting

Remove space

DATE=6/Jul/2010 6/Jul/2010 var="sed -n '/\ ---------- Post updated at 11:49 AM ---------- Previous update was at 11:36 AM ---------- #!/bin/bash DATE=`./get_date.pl 3` DATE1=`./get_date.pl 2` var1=$( echo "$DATE" | sed "s/ //g" ) var2=$( echo "$DATE1" | sed "s/ //g" ) var="sed -n... (1 Reply)
Discussion started by: sandy1028
1 Replies

9. UNIX for Dummies Questions & Answers

Space in file how to remove

Hello I have a file with data something like this in it : texttexttext "text .lst" TEXT=" text " texttexttext "moretext .lst" TEXT=" text " Question is how do I get rid of space so that the files looks like this : texttexttext "text.lst" TEXT="text" texttexttext... (8 Replies)
Discussion started by: davebw
8 Replies

10. Shell Programming and Scripting

how to get a space between the result of (date +%d) command

Hi I want to insert a space between the result of the following command. day=$(date %d) i get the result as ------- Sep 2 i want to get the result as Sep 2(two space between Sep and 2) how can i get this... is this possible wid awk??:confused: (12 Replies)
Discussion started by: ladtony
12 Replies

Featured Tech Videos