ALT Linux Community general discussions
 help / color / mirror / Atom feed
From: Vladimir Didenko <vladimir.didenko@gmail.com>
To: sp_archer@meta.ua,
	 ALT Linux Community general discussions
	<community@lists.altlinux.org>
Subject: Re: [Comm] срочно нужна помощь bash, awk или perl
Date: Thu, 8 Dec 2011 15:01:49 +0300
Message-ID: <CAHRK1yPijBaeoshSsq=K3-EJfiGh_ymP0DqWNBfG9CdaAeCUqw@mail.gmail.com> (raw)
In-Reply-To: <50454.194.44.242.194.1323344289.metamail@webmail.meta.ua>

[-- Attachment #1: Type: text/plain, Size: 612 bytes --]

8 декабря 2011 г. 15:38 пользователь Olexander Chernetskyy написал:
> Уже на форуме задал этот же вопрос. Но, извините очень срочно нужно.
>
> Есть текстовый файл с уймой строк фиксированой длины.
> поля в строке разделены запятыми. Длина полей фиксирована.
> пример строки:
>
> 021211083610,            ,QWERTYUIASDF,ZXCVBNMDFGGG,000001d9,N,Y,1
>
> В поле #5 содержится 16-ричное значение.
> Нужно срочно перелопатить это файл и заменить 16-ричное значение на
> 10-тичное.
>
> Заранее благодарен за помощь.
>

Перловский скрипт в аттаче.

Использование

./convert.pl input > output


-- 
С уважением,
Владимир.

[-- Attachment #2: convert.pl --]
[-- Type: text/x-perl, Size: 329 bytes --]

#!/usr/bin/perl

use strict;
use warnings; 

die "Usage: $0 <input file>" unless 1 == scalar @ARGV;

my $inp_fname = shift;

die "Cannot open $inp_fname\n" unless open(INP, $inp_fname);

while (my $line = <INP>)
{
    my @tokens = split(/,/, $line);
    $tokens[4] = hex($tokens[4]);
    print join(',', @tokens);
}

close(INP);

  reply	other threads:[~2011-12-08 12:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-08 11:38 Olexander Chernetskyy
2011-12-08 12:01 ` Vladimir Didenko [this message]
2011-12-08 13:05   ` Olexander Chernetskyy
2011-12-08 13:08     ` Michael Shigorin
2011-12-08 13:16       ` Olexander Chernetskyy
2011-12-08 13:20     ` Vladimir Didenko
2011-12-08 13:34       ` Olexander Chernetskyy
2011-12-08 12:18 ` Vladimir Karpinsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHRK1yPijBaeoshSsq=K3-EJfiGh_ymP0DqWNBfG9CdaAeCUqw@mail.gmail.com' \
    --to=vladimir.didenko@gmail.com \
    --cc=community@lists.altlinux.org \
    --cc=sp_archer@meta.ua \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux Community general discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/community/0 community/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 community community/ http://lore.altlinux.org/community \
		mandrake-russian@linuxteam.iplabs.ru community@lists.altlinux.org community@lists.altlinux.ru community@lists.altlinux.com
	public-inbox-index community

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.community


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git