Solved

how to AWK with the fix lenght

Posted on 2011-03-08
6
235 Views
Last Modified: 2012-05-11
how to get the variable in the string with the fixed size?

callXXXmain="|111                                  |222             |4444    |"

TempXXX=$(echo $callXXXmain | awk -F "|" '{print substr($25,1,70)}')
TempXXX="111 "

the TempXXX i only can get "111 " without any space.... what i need to get is, the variable with the spacing ...
0
Comment
Question by:gagajanice
  • 3
  • 3
6 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 35078050
callXXXmain="|111                                  |222             |4444    |"
TempXXX=$(echo "$callXXXmain" | awk -F "|" '{print substr($25,1,70)}')
echo "$TempXXX"
0
 
LVL 84

Expert Comment

by:ozo
ID: 35078055
callXXXmain="|111                                  |222             |4444    |"
TempXXX=$(echo "$callXXXmain" | awk -F "|" '{print substr($2,1,70)}')
echo "$TempXXX"
0
 

Author Comment

by:gagajanice
ID: 35078127
hi.. thankx
but i need to make the TempXXX to get the lenght in size 70

TempXXX="111                                                                 "
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:gagajanice
ID: 35078167
but

calXXXmain="|ABC DDK KLD        |aji |123   |"
TempXXX=$(echo $calXXXmain | awk -F "|" '{print substr($2,1)}')
TempXXX="`printf "%-70s" $TempXXX`"

but after it.. become   error
TempXXX="ABC                              DDK                      KLD                                                  "
0
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 35079474
calXXXmain="|ABC DDK KLD        |aji |123   |"
TempXXX=$(echo $calXXXmain | awk -F "|" '{print substr($2,1)}')
TempXXX=`printf "%-70s" "$TempXXX"`
0
 

Author Comment

by:gagajanice
ID: 35093319
thank you... it can work very fine!!
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now