Space being trimmed off

Hi All,

I am facing a peculiar situation. I have an output from some commands as below

# cat /export/home/FPPCCYHT | head -1 | cut -d"'" -f2 | cut -d"'" -f1
LLM10  01 0100:0240

If i assign this to a variable and then echo instead of 2 spaces only 1 space is appearing, meaning 1 space is being trimmed off.

# F2=`cat /export/home/FPPCCYHT | head -1 | cut -d"'" -f2 | cut -d"'" -f1`
# echo $F2
LLM10 01 0100:0240

expected O/P should be

LLM10  01 0100:0240

If any one wants the content of the file, first 3 lines are as below:

//FPPCCYHT JOB ,'LLM10  01 0100:0240',CLASS=P
//* REMT-08    JAN2009   MIGRATION(REHOSTING).  BGRND JOB.
//*

Let me know any other soultion

Regards,
Raghavendra

where is two spaces in your text :confused:

---------- Post updated at 12:18 PM ---------- Previous update was at 11:58 AM ----------

# echo "$F2"
1 Like
$ myvar="LLM10  01 0100:0240"
$ echo $myvar
LLM10 01 0100:0240
$ echo "$myvar"
LLM10  01 0100:0240
$

Use double quotes around the variable as ygemici and ranjithpr mentioned and instead of using several external programs this should be sufficient:

F2=`awk -F\' 'NR==1{print $2}' /export/home/FPPCCYHT`
echo "$F2"

or

 
# printf "%s\n" "$F2"

Thank you all.
Franklin please close this thread.