Sponsored Content
Top Forums UNIX for Dummies Questions & Answers AWK print last field including SPACES Post 302709369 by pamu on Wednesday 3rd of October 2012 07:18:03 AM
Old 10-03-2012
Code:
$ cat file
A0222|Y|DELACRUZ|-cc_dell@yahoo.com_-cc_support@yahoo.com

$ awk -F "|" '{ for(i=1;i<=NF;i++){if(i !=2){gsub("_"," ",$i);print $i}}}'
A0222
DELACRUZ
-cc dell@yahoo.com -cc support@yahoo.com

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Read files including spaces

I am accessing two files. I am using read command to read from the files. For the first file, I need read the fields delimited by spaces, and for the other file, I need to read the whole line as a single field including the spaces. When I used read command for the second file, the spaces... (4 Replies)
Discussion started by: kumariak
4 Replies

2. Shell Programming and Scripting

including spaces in awk output

I need to tweek my awk output: #cat filename ab cd ef:ghi:jk lm:nop qrs #cat filename | awk '{ for(i=3;i<NF+1;i++) printf $i}' ef:ghi:jklm:nopqrs I would like the ouput to include the original spaces from columns 3 on: ef:ghi:jk lm:nop qrs any suggestions? (4 Replies)
Discussion started by: prkfriryce
4 Replies

3. UNIX for Dummies Questions & Answers

Reading a line including spaces

Hi All, I have a script that reads a file and echo it back to std out. Test.txt 1aaaaaaaaaaa . The script is ReadLine.sh #!/bin/ksh cat $1 | while read file do echo $file done I invoke the script as ReadLine.sh Test.txt The output that I get is (1 Reply)
Discussion started by: aksarben
1 Replies

4. 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

5. UNIX for Dummies Questions & Answers

[awk] print from field n to field x

Hi, I'm trying to print every line from first field to the fourth from a file containing more. $ cat input a b c d e f g a b c d e f gI'm trying awk '{for (i=1; i <= NF-3; i++) print $i}' awkTest.datbut it printsa b c d a b c dSo, I easily guess I'm wrong. :) Of course, I want:a b... (5 Replies)
Discussion started by: daPeach
5 Replies

6. 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

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

8. 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

9. Shell Programming and Scripting

awk - CSV file - field with single or multiple spaces

Hi, In a csv file, I want to select records where first column has zero or multiple spaces. Eg: abc.csv ,123,a ,22,b ,11,c a,11,d So output should be: ,123,a ,22,b ,11,c Please advise (5 Replies)
Discussion started by: vegasluxor
5 Replies

10. Shell Programming and Scripting

awk print string with removing all spaces

Hi all, I want to set 10 set of strings into a variable where: removing all spaces within each string change the delimiter from "|" to "," Currently, I've the below script like this:Table=`ten character strings with spaces in-between and each string with delimiter "|" | tr -d ' ' |... (7 Replies)
Discussion started by: o1283c
7 Replies
GNC-FQ-HELPER(1)					User Contributed Perl Documentation					  GNC-FQ-HELPER(1)

NAME
gnc-fq-helper - allows gnucash to communicate with Finance::Quote over pipes from guile. The requests and responses are scheme forms. SYNOPSIS
gnc-fq-helper DESCRIPTION
Input: (on standard input - one entry per line and one line per entry, and double quotes must only be delimiters, not string content -- remember, we don't have a real scheme parser on the perl side :>). (<method-name> symbol symbol symbol ...) where <method-name> indicates the desired Finance::Quote method. The currently recognized subset is yahoo, yahoo_europe, fidelity_direct, troweprice_direct, vanguard, asx, tiaacref, and currency. For currency quotes, the symbols alternate between the 'from' and 'to' currencies. For example: (yahoo "IBM" "LNUX") (fidelity_direct "FBIOX" "FSELX") (currency "USD" "AUD") Output (on standard output, one output form per input line): Schemified version of gnc-fq's output, basically an alist of alists, as in the example below. Right now, only the fields that this script knows about (and knows how to convert to scheme) are returned, so the conversion function will have to be updated whenever Finance::Quote changes. Currently you'll get symbol, gnc:time-no-zone, and currency, and either last, nav, or price. Fields with gnc: prefixes are non-Finance::Quote fields. gnc:time-no-zone is returned as a string of the form "YYYY-MM-DD HH:MM:SS", basically the unmolested (and underspecified) output of the quote source. It's up to you to know what it's proper timezone really is. i.e. if you know the time was in America/Chicago, you'll need to convert it to that. For example: $ echo '(yahoo "CSCO" "JDSU" "^IXIC")' | ./gnc-fq-helper (("CSCO" (symbol . "CSCO") (gnc:time-no-zone . "2001-03-13 19:27:00") (last . 20.375) (currency . "USD")) ("JDSU" (symbol . "JDSU") (gnc:time-no-zone . "2001-03-13 19:27:00") (last . 23.5625) (currency . "USD")) ("^IXIC" (symbol . ^IXIC) (gnc:time-no-zone . 2002-12-04 17:16:00) (last . 1430.35) (currency . failed-conversion))) On error, the overall result may be #f, or on individual errors, the list sub-item for a given symbol may be #f, like this: $ echo '(yahoo "CSCO" "JDSU")' | ./gnc-fq-helper (#f ("JDSU" (symbol . "JDSU") (gnc:time-no-zone . "2001-03-13 19:27:00") (last . 23.5625) (currency . "USD"))) further, errors may be stored with each quote as indicated in Finance::Quote, and whenever the conversion to scheme data fails, the field will have the value 'failed-conversion, and accordingly this symbol will never be a legitimate conversion. Exit status 0 - success non-zero - failure perl v5.14.2 2013-01-03 GNC-FQ-HELPER(1)
All times are GMT -4. The time now is 11:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy