The previous post is only for GNU sed that is compiled with a recent glibc that has got the \S \s from perl (PCRE).
If you want portability, use the original! Most commercial Unixes have got perl.
This works, but in warning mode it says
Since perl 5.x it issues this warning. Fix: $n is like a variable that you can write ${n} (just like a variable in the shell).
Demo:
This User Gave Thanks to MadeInGermany For This Post:
Hi, Iam new to unix. I have one input file .
Input file :
ID1~Name1~Place1
ID2~Name2~Place2
ID3~Name3~Place3
I need output such that only first column should change to fixed width column of 15 characters of length.
Output File:
ID1<<12 spaces>>Name1~Place1
ID2<<12... (5 Replies)
Match column 3 in file1 to column 1 in file 2 and replace with column 2 from file2
file 1 sample
SNDK 80004C101 AT
XLNX 983919101 BB
NETL 64118B100 BS
AMD 007903107 CC
KLAC 482480100 DC
TER 880770102 KATS
ATHR 04743P108 KATS... (7 Replies)
Hi everyone, and thanks after all
I'm a biologist and i have to extract information from one text. The text is something like this
1023 A A 56 0 cc...,,,,..gg..Cc.c,,c..CC..,,
1024 T T 86 0 ..,,,..aaAA..,,aAA,,a,,A,,a
1025 G G 125 0 ... (5 Replies)
Hi
I wanted to fetch particular characters from a column.I have a file having columns separated by pipe operator.
The contents of the file are Task | Task started on a component | B678C56D-96DA-4FFC-B40E-9A032A2EB12E-0000004 | service.adapter:UCF Version Creator
... (2 Replies)
Hello all,
I have a data like this:
X:04252 X:05524 X:04176
X:05509 X:05524 X:04674-
X:1662912 X:10181
X:16491 X:05506
X:05216- X:05488
X:46872 X:08471
X:04834 X:30170
The except result is like this:
X:04252 X:05524 X:04176
X:05509 X:05524 X:04674
X:16629 X:10181... (3 Replies)
This is my input file :
# cat list 20130430121600, cucm, location,76,2 20130430121600,cucm1,location1,76,4 20130430122000,cucm,location,80,8 20130430122000,cucm1,location1,90,8 20130430140000,cucm1,location1,87,11 20130430140000, cucm,location,67,9
This is the required output
... (1 Reply)
I need to delete the last 11 characters from each number and they are all in the same line (each is in a different column):
-6.89080901827020800000 3.49348891708562325136 1.47988367839905286876 -2.29707635413510400000 -3.49342364708562325136 -4.43758473239905286876 -2.29707635413510400000... (14 Replies)
I have a file as follows
ATOM 5181 N AMET K 406 12.440 6.552 25.691 0.50 7.37 N
ATOM 5182 CA AMET K 406 13.685 5.798 25.578 0.50 5.87 C
ATOM 5183 C AMET K 406 14.045 5.179 26.909 0.50 5.07 C
ATOM 5184 O MET K... (14 Replies)
Hi,
My input files is like this
axis1 0 1 10
axis2 0 1 5
axis1 1 2 -4
axis2 2 3 -3
axis1 3 4 5
axis2 3 4 -1
axis1 4 5 -6
axis2 4 5 1
Now, these are my following tasks
1. Print a first column for every two rows that has the same value followed by a string.
2. Match on the... (3 Replies)
Hello all,
I want to consolidate my data group by cities into 4 rolled up code categories (first 2 characters of 2nd col), namely PR, GR, TY and others.
CHICAGO PR1
CHICAGO GR3
CHICAGO GR4
CHICAGO HT5
CHICAGO HT6
CHICAGO TY5
HOUSTON PR3
HOUSTON PR9
HOUSTON TY4
HOUSTON HJ5... (1 Reply)
Discussion started by: jalaj841
1 Replies
LEARN ABOUT OPENSOLARIS
unexpand
expand(1) User Commands expand(1)NAME
expand, unexpand - expand TAB characters to SPACE characters, and vice versa
SYNOPSIS
expand [-t tablist] [file]...
expand [-tabstop] [-tab1, tab2,. . ., tabn] [file]...
unexpand [-a] [-t tablist] [file]...
DESCRIPTION
The expand utility copies files (or the standard input) to the standard output, with TAB characters expanded to SPACE characters. BACKSPACE
characters are preserved into the output and decrement the column count for TAB calculations. expand is useful for pre-processing character
files (before sorting, looking at specific columns, and so forth) that contain TAB characters.
unexpand copies files (or the standard input) to the standard output, putting TAB characters back into the data. By default, only leading
SPACE and TAB characters are converted to strings of tabs, but this can be overridden by the -a option (see the OPTIONS section below).
OPTIONS
The following options are supported for expand:
-t tablist Specifies the tab stops. The argument tablist must consist of a single positive decimal integer or multiple posi-
tive decimal integers, separated by blank characters or commas, in ascending order. If a single number is given,
tabs will be set tablist column positions apart instead of the default 8. If multiple numbers are given, the tabs
will be set at those specific column positions.
Each tab-stop position N must be an integer value greater than zero, and the list must be in strictly ascending
order. This is taken to mean that, from the start of a line of output, tabbing to position N causes the next
character output to be in the (N+1)th column position on that line.
In the event of expand having to process a tab character at a position beyond the last of those specified in a
multiple tab-stop list, the tab character is replaced by a single space character in the output.
-tabstop Specifies as a single argument, sets TAB characters tabstop SPACE characters apart instead of the default 8.
-tab1,tab2,...,tabn Sets TAB characters at the columns specified by -tab1,tab2,...,tabn
The following options are supported for unexpand:
-a Inserts TAB characters when replacing a run of two or more SPACE characters would produce a smaller output file.
-t tablist Specifies the tab stops. The option-argument tablist must be a single argument consisting of a single positive decimal inte-
ger or multiple positive decimal integers, separated by blank characters or commas, in ascending order. If a single number
is given, tabs will be set tablist column positions apart instead of the default 8. If multiple numbers are given, the tabs
will be set at those specific column positions. Each tab-stop position N must be an integer value greater than zero, and the
list must be in strictly ascending order. This is taken to mean that, from the start of a line of output, tabbing to posi-
tion N will cause the next character output to be in the (N+1)th column position on that line. When the -t option is not
specified, the default is the equivalent of specifying -t 8 (except for the interaction with -a, described below).
No space-to-tab character conversions occur for characters at positions beyond the last of those specified in a multiple
tab-stop list.
When -t is specified, the presence or absence of the -a option is ignored; conversion will not be limited to the processing
of leading blank characters.
OPERANDS
The following ooperand is supported for expand and unexpand:
file The path name of a text file to be used as input.
ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of expand and unexpand: LANG, LC_ALL,
LC_CTYPE, LC_MESSAGES, and NLSPATH.
EXIT STATUS
The following exit values are returned:
0 Successful completion
>0 An error occurred.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWesu |
+-----------------------------+-----------------------------+
|CSI |enabled |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
SEE ALSO tabs(1), attributes(5), environ(5), standards(5)SunOS 5.11 1 Feb 1995 expand(1)