This is the format of my log file and parameters for log file are like
• 10 first characters: MSISDN
• 6 next characters: Hour
• 18 next characters: ID SA Source
• 18 next characters: ID SA Destination
I have 11 whitespaces in between my first and second colums.I need to cut fitst 10 char next 6 char and next 18 char(including white spaces) . and i tried follwing in my code
This is the format of my log file and parameters for log file are like
• 10 first characters: MSISDN
• 6 next characters: Hour
• 18 next characters: ID SA Source
• 18 next characters: ID SA Destination
I have 11 whitespaces in between my first and second colums.I need to cut fitst 10 char next 6 char and next 18 char(including white spaces) . and i tried follwing in my code
But i cant trim my whitespaces from log files . i need to take that also..
becos parameters are set like
• 10 first characters: MSISDN
• 6 next characters: Hour
• 18 next characters: ID SA Source
• 18 next characters: ID SA Destination
This characters includes white spaces also
But i cant trim my whitespaces from log files . i need to take that also..
becos parameters are set like
• 10 first characters: MSISDN
• 6 next characters: Hour
• 18 next characters: ID SA Source
• 18 next characters: ID SA Destination
This characters includes white spaces also
Actually the log file is like 0608166896000001 in my first column 11 whitespaces and 3001339 in my second column( 3001339) then 11 whitespaces and
3204235 in my third coumn . ...
But while reading line by line using following code
while read data
do
echo data $data
ID_SA_SOURCE=`echo $data | cut -c17-35`
echo ID_SA_SOURCE $ID_SA_SOURCE
done < $TRACKING_LOGDIR/$listdata
I am not getting the 11 white spaces in "data" variable instead of i am getting only one space..i want 11whtespaces first and 3001339 value in my ID_SA_SOURCE variable....
You need to properly quote your variables when you echo them, otherwise the shell will trim whitespace. I'd advise against using echo at all, though.
But here's how to quote properly. To be a little bit on the safe side, I also zap IFS; I don't believe it's strictly necessary here, but it's a technique you should be aware of.
Having that out of the way, how about something like this?
I am using : << cut / cut to comment out block of code.
Works fine on few lines of script, then it gives me this cryptic error when I try to comment out about 80 lines.
The "warning " is at last line of script.
done < results
169 echo "END read all positioning parameters"
170... (8 Replies)
I'm a complete beginner in UNIX (and not a computer science student either), just undergoing a tutoring course. Trying to replicate the instructions on my own I directed output of the ls listing command (lists all files of my home directory ) to My_dir.tsv file (see the screenshot) to make use of... (9 Replies)
Hi
Can anyone what I am doing wrong while using cut command.
for f in *.log
do
logfilename=$f
Log "Log file Name: $logfilename"
logfile1=`basename $logfilename .log`
flength=${#logfile1}
Log "file length $flength"
from_length=$(($flength - 15))
Log "from... (2 Replies)