Sponsored Content
Full Discussion: Fomatting o/p
Top Forums Shell Programming and Scripting Fomatting o/p Post 302928452 by gvkumar25 on Thursday 11th of December 2014 06:23:42 PM
Old 12-11-2014
Fomatting o/p

Hi Team,

I am getting newline character when I ran below script.

What I doing in the script is just formatting the input provided to that script and printing.

Code:
Output_Logging()
{
var=$1
tmp=`echo $var | cut -b 1-140`
echo "[INFO][`date +'%h %d %H:%M:%S'`]  $tmp"
var1=`echo $var | cut -b 141-|sed 's#\\\\n##g`
while true
do
if [ -z "$var1" ]
then
break
fi
x=`echo $var1 | cut -b 1-140`
echo "\t\t\t $x"
var1=`echo $var1 | cut -b 141-`
done
}
# Begin Main
if [ $# -eq 0 ]
then
   if [ -t 0 ]
   then
     echo "[INFO]   Please Input the string which you want to format"
   fi
     read input
     Output_Logging "$input"
else
   input=$@
   Output_Logging "$input"
fi

I am not getting why newline character is getting printed when I ran my script

Code:
output_log "hello"
+ [ 1 -eq 0 ]
+ input=hello
+ Output_Logging hello
[INFO][Dec 11 14:51:31]  hello
  --newline charchter here

---------- Post updated at 06:11 PM ---------- Previous update was at 05:55 PM ----------

---------- Post updated at 06:23 PM ---------- Previous update was at 06:11 PM ----------

got the error

Last edited by gvkumar25; 12-11-2014 at 07:20 PM..
 

We Also Found This Discussion For You

1. UNIX for Dummies Questions & Answers

Fomatting Solaris Hard Disk.

Hi Friends ! How long does it take to format a hard disk under Solaris ? Once the format starts, what data will be cleared or deleted first ? i.e whether the OS is cleared or all the data other than OS is cleared first ? Then, if the format starts and the power goes off, can i retrieve data?... (1 Reply)
Discussion started by: mrgubbala
1 Replies
All times are GMT -4. The time now is 10:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy