Search Results

Search: Posts Made By: samoptimus
3
3,301
Posted By rdcwayx
awk 'NR==FNR{t=$1;sub($1 "...
awk 'NR==FNR{t=$1;sub($1 " ","",$0);a[t]=$0;next}{print a[$1] RS $0 RS}' 2.txt 1.txt
1,245
Posted By pludi
Or shorter:sort file | uniq -c
Or shorter:sort file | uniq -c
3,493
Posted By yazu
Without a loop: $ cat testfile | sed -r...
Without a loop:

$ cat testfile | sed -r 's/^([0-9]+)-/\1 /' | xargs printf "%04d %s %s %d %d\n"
0281 BUM-5M BUM-5M 0 0
0282 BUM-5M BUM-5M 0 0
0083 BUM-5M BUM-5M 0 0

Or (for our pedants):
...
3,493
Posted By agama
This is a pure shell solution - should work in...
This is a pure shell solution - should work in bash as well.


#!/usr/bin/env ksh

while read first rest
do
printf "%04d %s %s\n" ${first/-/ } "$rest"
done <data-file
exit
3,493
Posted By guruprasadpr
Hi awk...
Hi

awk '{x=substr($0,1,index($0,"-")-1);y=substr($0,index($0,"-")+1);printf "%04d %s\n",x,y;}' file

Guru.
Showing results 1 to 5 of 5

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