Sponsored Content
Top Forums Shell Programming and Scripting awk print string with removing all spaces Post 302945094 by o1283c on Tuesday 26th of May 2015 06:51:07 AM
Old 05-26-2015
Hi Clx,

The input was come from a api command's output and the format as follows:
Code:
aaa1|bbbb1   | cc1   | dddd ddd1 |eee eee eee1|ff1|gg1|hh1|ii1|jj1
aaa2|bbbb2   | cc2   | dddd ddd2 |eee eee eee2|ff2|gg2|hh2|ii2|jj2
aaa3|bbbb3   | cc3   | dddd ddd3 |eee eee eee3|ff3|gg3|hh3|ii3|jj3

and I want to have the output from awk -F'|' '{print $1","$2","$3","$4","$5","$6","$7","$8","$9","$10}'` becomes:
Code:
aaa1,bbbb1,cc1,dddd ddd1,eee eee eee1,ff1,gg1,hh1,ii1,jj1
aaa2,bbbb2,cc2,dddd ddd2,eee eee eee2,ff2,gg2,hh2,ii2,jj2
aaa3,bbbb3,cc3,dddd ddd3,eee eee eee3,ff3,gg3,hh3,ii3,jj3

then finally set the output from awk to the variable Table (for some reasons that I don't want to use file so that's why I keep using pipe and then put all result records into a variable)

Paul

Last edited by rbatte1; 05-26-2015 at 01:20 PM.. Reason: Added CODE tags for data
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to print arguments along with spaces using awk

Hi All, file_1.txt contains aaa bbbb hhhh vvvvv mmmmm iiiii What i want is to search for the first coloumn of each line using awk.i.e as below: awk '/aaa/ {printf(<>)}' file_1.txt The print part (<>) should contain all the values(or coloumns ) in the particular line(here it... (8 Replies)
Discussion started by: jisha
8 Replies

2. Shell Programming and Scripting

Removing spaces from string

I want a user to be able to paste in a string like "01 3F 20 1F" and have the script reformat it to "013F201F" to pass it on to the next step. I was trying to figure it out with awk but wasnt working well. Never mind, found answer. did not know about tr :) (7 Replies)
Discussion started by: ippy98
7 Replies

3. Shell Programming and Scripting

Removing blank spaces, tab spaces from file

Hello All, I am trying to remove all tabspaces and all blankspaces from my file using sed & awk, but not getting proper code. Please help me out. My file is like this (<b> means one blank space, <t> means one tab space)- $ cat file NARESH<b><b><b>KUMAR<t><t>PRADHAN... (3 Replies)
Discussion started by: NARESH1302
3 Replies

4. Shell Programming and Scripting

Print filenames with spaces using awk

Hello all, I want to list the file contents of the directory and number them. I am using la and awk to do it now, #ls |awk '{print NR "." $1}' 1. alpha 2. beta 3. gamma The problem I have is that some files might also have some spaces in the filenames. #ls alpha beta gamma ... (7 Replies)
Discussion started by: grajp002
7 Replies

5. Shell Programming and Scripting

Print the string between spaces

How to print the strings within a line between two spaces . <ns1:providerErrorCode>141</ns1:providerErrorCode> <ns1:providerErrorText>business_rule_exception-Server.404:Cannot proceed because the subscriber with phone number is either suspended or the account has an unpaid... (8 Replies)
Discussion started by: raghunsi
8 Replies

6. UNIX for Dummies Questions & Answers

Print files with spaces using awk

When I use: find . -ls | awk 'BEGIN { OFS = ";"} {print $1,$2,$11}'I get a nice result, yet the files with spaces in it show only the first word and all other characters after the blank space are not printed. e.g. 'file with a blank space' is printed file 'file_with a blank space' is... (7 Replies)
Discussion started by: dakke
7 Replies

7. Shell Programming and Scripting

Removing columns from awk '{ print $0 }'

I have a one-line command, lsusb | awk '{ $1=""; $2=""; $3=""; $4=""; $5=""; $6=""; print $0 }' It works, and gives the results I expect, I was just wondering if I am missing some easier way to nullify the first 6 column variables? Something like, lsusb | awk '{ $(1-6)=""; print $0 }' But... (10 Replies)
Discussion started by: AlphaLexman
10 Replies

8. Shell Programming and Scripting

awk for removing spaces

HI, I have a file with lot of blank lines, how can I remove those using awk?? Thanks, Shruthi (4 Replies)
Discussion started by: shruthidwh
4 Replies

9. UNIX for Dummies Questions & Answers

AWK print last field including SPACES

I have simple test.sh script, see below: bill_code=`echo $record | awk -F"|" '{print $1}'` Fullname=`echo $record | awk -F"|" '{print $3}'` email=`echo $record | awk -F\ '{print $4}'` The last field contains spaces: see csv below: A0222|Y|DELACRUZ|-cc dell@yahoo.com-cc support@yahoo.com ... (9 Replies)
Discussion started by: quay
9 Replies

10. Shell Programming and Scripting

awk - print columns with text and spaces

Hi, I'm using awk to print columns from a tab delimited text file: awk '{print " "$2" "$3" $6"}' file The problem I have is column 6 contains text with spaces etc which means awk only prints the first word. How can I tell awk to print the whole column content as column 6? Thanks, (10 Replies)
Discussion started by: keenboy100
10 Replies
M16C-FLASH(1)						      General Commands Manual						     M16C-FLASH(1)

NAME
m16c-flash - Flash programmer for Renesas M16C and R8C microcontrollers SYNOPSIS
m16c-flash [COM_DEV] [CPU_TYPE] [FILE] [ID1:...:ID7] [OPTIONS] DESCRIPTION
m16c-flash is a flash programmer for the Renesas M16C and R8C microcontrollers which operates in asynchronous mode. OPTIONS
COM_DEV The serial device to use for flashing, e.g. /dev/ttyS0 or /dev/ttyUSB0. CPU_TYPE The CPU type you want to flash to (currently M16C or R8C). FILE The filename of the binary you want to flash. ID1:...:ID7 The device ID. --help Show a help text and exit. --version Show version information and exit. EXAMPLES
Flash the simple.s file onto an M16C microcontroller via the first serial port (/dev/ttyS0) using 0:0:0:0:0:0:0 as the device ID: m16c-flash /dev/ttyS0 M16C simple.s 0:0:0:0:0:0:0 Flash the test.mot file onto an R8C microcontroller via the USB serial device /dev/ttyUSB0, and using ff:ff:ff:ff:ff:ff:ff as device ID: m16c-flash /dev/ttyUSB0 R8C test.mot ff:ff:ff:ff:ff:ff:ff BUGS
Please report any bugs to Thomas Fischl <tfischl@gmx.de>. LICENCE
m16c-flash is covered by the GNU General Public License (GPL). AUTHORS
Greg Reynolds <greg@lostintheether.net> Jim Hawkridge <h046@eee-fs4.bham.ac.uk> Thomas Fischl <tfischl@gmx.de> This manual page was written by Uwe Hermann <uwe@hermann-uwe.de>, for the Debian GNU/Linux system (but may be used by others). August 20, 2006 M16C-FLASH(1)
All times are GMT -4. The time now is 08:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy