Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

how to AWK with the fix lenght

Posted on 2011-03-08
6
Medium Priority
?
242 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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 2000 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

636 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