10 More Discussions You Might Find Interesting
1. UNIX for Beginners Questions & Answers
Hi,
I have a file where I need to change the date format on the nth field from DD-MM-YYYY to YYYY-MM-DD so I can accurately sort the record by dates
From regex - Use sed or awk to fix date format - Stack Overflow, I found an example using nawk.
Test run as below:
$: cat xyz.txt
A ... (2 Replies)
Discussion started by: newbie_01
2 Replies
2. Shell Programming and Scripting
Example:
Input csv file
00245DLS,Sitel Ocala,12/31/2014,18:45,1.00,7.00,0.00,0.00
00245DLS,Sitel Ocala,12/31/2014,19:00,-1.00,-1.00,-1.00,-1.00
00245HB,Charlotte,01/01/2015,00:00,-1.00,-1.00,-1.00,0.00
Output csv file
00245DLS,Sitel Ocala,2014/12/31,18:45,1.00,7.00,0.00,0.00
00245DLS,Sitel... (8 Replies)
Discussion started by: adit
8 Replies
3. Shell Programming and Scripting
I have a csv file formatted like this:
2014-08-21 18:06:26,A,B,12345,123,C,1232,26/08/14 18:07and I'm trying to change it to MM/DD/YYYY HH:MM for both occurances.
I have got this:
awk -F, 'NR <=1 {print;next}{"date +%d/%m/%Y\" \"%H:%m -d\""$1 "\""| getline dte;$1=dte}1' OFS="," test.csvThis... (6 Replies)
Discussion started by: say170
6 Replies
4. UNIX for Dummies Questions & Answers
Greetings!
I need a quick way to change the format in a table of data
Here is an example of the input:
10 72 Value=177 VDB=0.0245 Value4=0,0,171,0
10 274 Value=238 VDB=0.0433 Value4=29,0,205,0
10 312 Value=222 VDB=0.0384 Value4=8,0,190,19
10 540 Value=405 VDB=0.0391 Value4=13,30,153,195... (3 Replies)
Discussion started by: Twinklefingers
3 Replies
5. Shell Programming and Scripting
I have below date format in a CSV file. (dd/mm/yyyy)
Ex Input:
9/8/2013
Need to convert it into below format (yyyymmdd ) and redirect to new file.
Ex Output:
20130809
How do I use awk here to change the format and if leading 0 (zero) is not then add it.
Please help. Thanks. (8 Replies)
Discussion started by: vegasluxor
8 Replies
6. Shell Programming and Scripting
Hi,
i have a file input.txt
Continent North America
Country USA Capital Washington D.C.
Country Canada Capital Ottawa
Continent South America
Country Argentina Capital Buenos Aires
Country Brazil Capital Brasília
Coutry Colombia Capital Bogotá
and i want to get an output.txt
... (3 Replies)
Discussion started by: fastlane3000
3 Replies
7. Shell Programming and Scripting
tenxun-glibc_code-x86-64-linux-20120713190049.root.tar.bz2
To
tenxun-glibc_code-x86-64-linux.root.tar.bz2 (3 Replies)
Discussion started by: yanglei_fage
3 Replies
8. Shell Programming and Scripting
Hello,
Can you tell me how can I change this format by awk
Input
0.2057422D-01
0.2463722D-01
-0.1068047D-02
Output
0.02057422
0.02463722
-0.001068047
Thanks
wan (8 Replies)
Discussion started by: wanchem
8 Replies
9. Shell Programming and Scripting
Hi Everyone,
# cat 1.txt
1321631,77770132976455,19,20091001011859,20091001011907
1321631,77770132976455,19,20091001011859,20091001011907
1321631,77770132976455,19,20091001011859,20091001011907
# cat 1.txt | awk -F, '{OFS=",";print $1,$3,$4,$5}'
1321631,19,20091001011859,20091001011907... (7 Replies)
Discussion started by: jimmy_y
7 Replies
10. Shell Programming and Scripting
I have about 300 files which has the function getDBBackend().
How to write a program to change the empty function from the old format to the new format?
Old empty function format are either:
function getDBBackend()
{
// Not available
} // getDBBackend
or:
function... (0 Replies)
Discussion started by: powah
0 Replies
AGGREGATE(1) General Commands Manual AGGREGATE(1)
NAME
aggregate - optimise a list of route prefixes to help make nice short filters
SYNOPSIS
aggregate [-m max-length] [-o max-opt-length] [-p default-length] [-q] [-t] [-v]
DESCRIPTION
Takes a list of prefixes in conventional format on stdin, and performs two optimisations to attempt to reduce the length of the prefix
list.
The first optimisation is to remove any supplied prefixes which are superfluous because they are already included in another supplied pre-
fix. For example, 203.97.2.0/24 would be removed if 203.97.0.0/17 was also supplied.
The second optimisation identifies adjacent prefixes that can be combined under a single, shorter-length prefix. For example, 203.97.2.0/24
and 203.97.3.0/24 can be combined into the single prefix 203.97.2.0/23.
OPTIONS
-m max-length
Sets the maximum prefix length for entries read from stdin max_length bits. The default is 32. Prefixes with longer lengths will be
discarded prior to processing.
-o max-opt-length
Sets the maximum prefix length for optimisation to max-opt-length bits. The default is 32. Prefixes with longer lengths will not be
subject to optimisation.
-p default-length
Sets the default prefix length. There is no default; without this option a prefix without a mask length is treated as invalid. Use
-p 32 -m 32 -o 32 to aggregate a list of host routes specified as bare addresses, for example.
-q Sets quiet mode -- instructs aggregate never to generate warning messages or other output on stderr.
-t Silently truncate prefixes that seem to have an inconsistent prefix: e.g. an input prefix 203.97.2.226/24 would be truncated to
203.97.2.0/24. Without this option an input prefix 203.97.2.226/24 would not be accepted, and a warning about the inconsistent mask
would be generated.
-v Sets verbose mode. This changes the output format to display the source line number that the prefix was obtained from, together with
a preceding "-" to indicate a route that can be suppressed, or a "+" to indicate a shorter-prefix aggregate that was added by aggre-
gate as an adjacency optimisation. Note that verbose output continues even if -q is selected.
DIAGNOSTICS
Aggregate exits 0 on success, and >0 if an error occurs.
EXAMPLES
The following list of prefixes:
193.58.204.0/22
193.58.208.0/22
193.193.160.0/22
193.193.168.0/22
193.243.164.0/22
194.126.128.0/22
194.126.132.0/22
194.126.134.0/23
194.151.128.0/19
195.42.240.0/21
195.240.0.0/16
195.241.0.0/16
is optimised as followed by aggregate (output shown using the -v flag):
aggregate: maximum prefix length permitted will be 24
[ 0] + 193.58.204.0/21
[ 1] - 193.58.204.0/22
[ 2] - 193.58.208.0/22
[ 3] 193.193.160.0/22
[ 4] 193.193.168.0/22
[ 5] 193.243.164.0/22
[ 0] + 194.126.128.0/21
[ 6] - 194.126.128.0/22
[ 7] - 194.126.132.0/22
[ 8] - 194.126.134.0/23
[ 9] 194.151.128.0/19
[ 10] 195.42.240.0/21
[ 0] + 195.240.0.0/15
[ 11] - 195.240.0.0/16
[ 12] - 195.241.0.0/16
Note that 193.58.204.0/22 and 193.58.208.0/22 were combined under the single prefix 193.58.204.0/21, and 194.126.134.0/23 was suppressed
because it was included in 194.126.132.0/22. The number in square brackets at the beginning of each line indicates the original line num-
ber, or zero for new prefixes that were introduced by aggregate.
The output without the -v flag is as follows:
193.58.204.0/21
193.193.160.0/22
193.193.168.0/22
193.243.164.0/22
194.126.128.0/21
194.151.128.0/19
195.42.240.0/21
195.240.0.0/15
SEE ALSO
aggregate-ios(1)
HISTORY
Aggregate was written by Joe Abley <jabley@mfnx.net>, and has been reasonably well tested. It is suitable for reducing customer prefix fil-
ters for production use without extensive hand-proving of results.
Autoconf bits were donated by Michael Shields <michael.shields@mfn.com>. The -t option was suggested by Robin Johnson <rob-
bat2@fermi.orbis-terrarum.net>, and the treatment of leading zeros on octet parsing was changed following comments from Arnold Nipper
<arnold@nipper.de>.
An early version of aggregate would attempt to combine adjacent prefixes regardless of whether the first prefix lay on an appropriate bit
boundary or not (pointed out with great restraint by Robert Noland <rnoland@2hip.net>).
BUGS
Common unix parsing of IPv4 addresses understands the representation of individual octets in octal or hexadecimal, following a "0" or "0x"
prefix, respectively. That convention has been deliberately disabled here, since resources such as the IRR do not follow the convention,
and confusion can result.
For extremely sensitive applications, judicious use of the -v option together with a pencil and paper is probably advisable.
Joe Abley 2001 November 2 AGGREGATE(1)