08-01-2012
Yes, I guess it may appear a bit cryptic..
It uses a double quote as input and output record selector (RS=\" ORS=\"). So any record is either inside or outside double quotes. The mod of the line number divided by 2 ( (NR-1)%2 ) determines which is the case. If it is the case then $1=$1 is used to replace any occurrence of the default input field selector (FS), i.e. any combination of consecutive spaces, TABs or newlines to be replaced by the default output field selector (OFS), which is a single space...
The 1 is synonymous for "print the record"..
This User Gave Thanks to Scrutinizer For This Post:
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi,
I am trying to write a script to prepare some text for use as web content.
What is happening is that all the newlines in the textfile are ignored, so I want
to be able to replace/add a few characters so that for a file containg:
This is line 1.
This is line two.
This is line four.... (1 Reply)
Discussion started by: ghoti
1 Replies
2. UNIX for Advanced & Expert Users
no problem (6 Replies)
Discussion started by: angelina
6 Replies
3. Shell Programming and Scripting
Input:
--------------------------
123asd 456sdasda 789a
-------------------------
output wanted:
---------------------
123asd
456sdasda
789a
----------------------
I want this by sed in simple way
please help (I know by: tr ' ' '\n' < inputfile )I want it by sed only (5 Replies)
Discussion started by: RahulJoshi
5 Replies
4. Shell Programming and Scripting
Hi,
I have data as
"01/22/97-"aaaaaaaaaaaaaaaaa""aaa""aabbbbbbbbcccccc""zbcd""dddddddddeeeeeeeeefffffff"
I want to remove only the Consequitive double quotes and not the one which occurs single.
My O/P must be ... (2 Replies)
Discussion started by: Bhuvaneswari
2 Replies
5. Shell Programming and Scripting
I have file with SQL output as
0001 firstname1 lastname1 0002 firstname2 lastname2 0003 firstname3 lastname3 0004 firstname4 lastname4
Expected output :
0001 firstname1 lastname1
0002 firstname2 lastname2
0003 firstname3 lastname3
0004 firstname4 lastname4
Let me know if this can... (9 Replies)
Discussion started by: sameermohite
9 Replies
6. Shell Programming and Scripting
Hi Froum.
I have tried in vain to find a solution for this problem - I'm trying to replace any double quotes within a quoted string with a single quote, leaving everything else as is.
I have the following data:
Before:
... (32 Replies)
Discussion started by: pchang
32 Replies
7. Shell Programming and Scripting
Hi All,
I'm unable to load the data using sql loader where there are double quotes within the double quotes As these are optionally enclosed by double quotes.
Sample Data :
"221100",138.00,"D","0019/1477","44012075","49938","49938/15043000","Television - 22" Refurbished - Airwave","Supply... (6 Replies)
Discussion started by: mlavanya
6 Replies
8. Shell Programming and Scripting
Hello
I have had a requirement where I need to move data to a new line based on a text .So basically as soon as it encounters :61: it should move to a new line
Source Data :
:61:D100,74NCH1 :61:D797,50NCH2 :61:D89,38NCHK2 :61:D99,38NCHK12 :61:D79,38NCHK22 :61:D29,38NCHK5
Target Data... (11 Replies)
Discussion started by: kamijia83
11 Replies
9. Shell Programming and Scripting
i have an output that i receive and it looks like this:
echo '/var/FTPROOT/px/sci/archive/20171102070057904-DY_DC04_Daily Inventory Sync-en-us.csv' '/var/FTPROOT/px/sci/archive/20171102070058291-DY_DC07_Daily Inventory Sync-en-us.csv'
what i want to do is replace the spaces in the file names... (2 Replies)
Discussion started by: SkySmart
2 Replies
10. UNIX for Beginners Questions & Answers
Hi,
I have below requirement.
Apple
Orange
Banana
Required O/p in bash
'Apple,Orange,Banana'
Can you please help.
Please wrap your samples, codes in CODE TAGS as per forum rules. (3 Replies)
Discussion started by: Rtk
3 Replies
LEARN ABOUT DEBIAN
nl-pktloc-lookup
nl-pktloc-lookup(8) System Manager's Manual nl-pktloc-lookup(8)
NAME
nl-pktloc-lookup - Lookup packet location definitions
SYNOPSIS
nl-pktloc-lookup name
nl-pktloc-lookup --list
DESCRIPTION
nl-pktloc-lookup searches the packet location database for a matching entry. It is used to resolve packet location aliases to their defini-
tion, i.e. alignment, layer, offset, and mask.
OPTIONS
-h or --help
Print help text to console and exit.
-v or --version
Print versioning information to console and exit.
-l or --list
List all packet location definitions.
--u32=VALUE
Prints the packet location definition in a special format that is understood by iproute2's u32 selector parser. It will output a u32
selector which will compare the provided value with the value specified by the packet location.
Please note that due to the limitation of u32, it is not possible to use packet locations based on the link layer. nl-pktloc-lookup
will print an error message in this case.
Example:
selector=$(nl-pktloc-lookup --u32 22 tcp.sport)
tc filter add [...] u32 match $(selector) flowid 1:2
FILES
/etc/libnl/pktloc
AUTHOR
Thomas Graf is the original author and current maintainer of libnl and libnl tools. Many people have contributed to it since.
libnl 27 October 2010 nl-pktloc-lookup(8)