Search Results

Search: Posts Made By: nex_asp
2,688
Posted By itkamaraj
#! /usr/bin/perl -w use strict; open...
#! /usr/bin/perl -w
use strict;
open FP1,"A.txt";
open FP2,"B.txt";
open FP3, ">A_B.txt" or die $!;
my ($l1,$l2);
while(1)
{
$l1=<FP1>; chomp $l1;
$l2=<FP2>; chomp $l2;
last...
12,448
Posted By Jotne
awk 'split($2,t,":") {if (t[1]>12) {print...
awk 'split($2,t,":") {if (t[1]>12) {print $1,t[1]-12":"t[2]":"t[3]" PM",$3,$4} else {print $1,t[1]+0":"t[2]":"t[3]" AM",$3,$4}}' file
13-Nov-2011 1:27:36 PM 15.32044 72.68502
13-Nov-2011 12:08:31...
12,448
Posted By pamu
Try sth like this.. awk -F ":| +"...
Try sth like this..


awk -F ":| +" '{if($2>12){t=sprintf("%02d", $2-12);print $1,t":"$3":"$4,"PM"}else{print $1,$2":"$3":"$4,"AM"}}' file
12,448
Posted By Don Cragun
The above suggestions don't strip off input...
The above suggestions don't strip off input fields 3 and 4. If you want something matching the output you said you want, try something like:
awk '{ split($2, df, /:/)
$2 =...
12,448
Posted By Yoda
awk ' { split($2,A,":"); if(A[1]>12) { ...
awk ' {
split($2,A,":");
if(A[1]>12) {
V=sprintf("%02d",A[1]-12);
sub(/[0-9]+:/,V":",$2);
$2=$2" PM";
}
else if(A[1]==12)
$2=$2" PM";
else if(A[1]==0) {
...
9,393
Posted By pamu
Check Your below command you should use _ there :)
Check Your below command you should use _ there :)
9,393
Posted By pamu
Hope this is what you want.. awk 'FNR == 2...
Hope this is what you want..

awk 'FNR == 2 {print FILENAME,$1,$2,$3,$4,$5,$6}' *.txt >> new.xyz
1,349
Posted By srinivas matta
if the units are equl to 10 after id- then you...
if the units are equl to 10 after id- then you can use below code.


sed "s/id-........../my_datafile/g" $file > output
5,082
Posted By RudiC
For "cleaning" dos files, use the dos2unix...
For "cleaning" dos files, use the dos2unix command, if available. Other very powerful and helpful programs are iconv or recode. For just removing the <CR> chars, tr -d "\r" <ifile >ofile will do.
...
5,082
Posted By Don Cragun
Sorry, the /]r/ should have been /\r/. I don't...
Sorry, the /]r/ should have been /\r/. I don't have time to work out what you need for FS and OFS; you might try just removing the place where you set FS; the default value may work with your latest...
5,082
Posted By RudiC
Try gsub(/\r/, "") instead (typo?). And, as...
Try gsub(/\r/, "") instead (typo?).

And, as Don Cragun stated, your files are contaminated with windows style characters, repeatedly (https://www.unix.com/302754801-post6.html). Why don't you...
9,273
Posted By RudiC
This is not only not easy, but some records will...
This is not only not easy, but some records will be impossible to translate, be it manually or by program logic - those using two numbers below 13 for day and month in an undefined order. These will...
2,686
Posted By guruprasadpr
Hi Pipe your file listing output to this...
Hi

Pipe your file listing output to this command:

sort -t"-" -k2n,2
2,061
Posted By RudiC
Works perfectly for me - once I've eliminated or...
Works perfectly for me - once I've eliminated or corrected for the errors in your files.
a) field separator in data.txt is just a comma, not comma space as in your sample
b) extra empty line at the...
2,265
Posted By Scrutinizer
Try: awk 'NR==1 || $1<p{close(f); f="newfile_"...
Try:
awk 'NR==1 || $1<p{close(f); f="newfile_" ++n}{print>f; p=$1}' infile
2,772
Posted By itkamaraj
$ perl -lane 's/[()\]\[]//g;print $_ if...
$ perl -lane 's/[()\]\[]//g;print $_ if $F[5]!=9999' input.txt
34.4 4 00 1 3 1 110 3 3 00
34.38 4 00 1 3 12 165 3 3 00...
2,772
Posted By michaelrozar17
Alternate awk.. $ uname -rs SunOS 5.10 $...
Alternate awk..
$ uname -rs
SunOS 5.10
$ nawk '$6!="9999"{gsub(/[)(\]\[]/,"",$0);print}' inputfile
2,772
Posted By pamu
Is this what you want.. $ cat file 2.16 ...
Is this what you want..

$ cat file
2.16 (3) [00] 1 3 9999 0 (1) (0) [00]
34.42 (4) [00] 1 3 9999 37 (2) (3) [00]...
2,772
Posted By pamu
Please use code tags.. Assuming you have...
Please use code tags..

Assuming you have sorted input.
Try
$ cat file1
1 25 35
2 25 32
3 25 32
4 24 35
5 23 38
6 17 15
4 58 35
3 15 36
2 25 33
1 25 35
0 25 38

$ awk '$1 > s ||...
5,082
Posted By Don Cragun
Try saving the following script in a file (I used...
Try saving the following script in a file (I used the name runner while testing it, but choose anything you like). Make it executable using chmod +x file_name and run it using ./runner header.txt...
Showing results 1 to 20 of 20

 
All times are GMT -4. The time now is 08:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy