Sponsored Content
Full Discussion: Text Translation
Special Forums UNIX Desktop Questions & Answers Text Translation Post 302500753 by PG3 on Tuesday 1st of March 2011 12:08:47 PM
Old 03-01-2011
Text Translation

hi all,
Im a unix newbie and Im trying to find and replace text and I been looking at these posts since 7 am and I still dont see what Im
after.
Here is the task at hand. Im trying to translate few lines by doing cat <file> and here is what Im doing
<file>
Code:
20110228 Mike Original apartment costed almost 23277AA
20110130 And few of the upgrades alone were into few hundred thousand dollars 47738
20110219 BUT THAT WAs magical and everyone was so elated to see 93884
20110222 so would you want to join us 38488

<expected file>
Code:
20110228 TEXT1 23277AA
20110130 TEXT2 47738
20110219 TEXT3 93884
20110222 TEXT4 38488

in other words
if the line contains the word, original, then replace that entire text(only alphabets) line with "TEXT1"
if the line contains the word, dollars, then replace entire text with "TEXT2"
if the line contains the word, magical, then replace entire text with "TEXT3"
if the line contains the word, join, then replace entire text with "TEXT4"
Code:
cat <file> | awk '$0 ~/original/ { sub($0, "TEXT1"; print }'

but that is not working as I dont know what Im doing here.

Please help !

Thanks,
PGonzalez

Last edited by Scott; 03-01-2011 at 02:19 PM.. Reason: Please use code tags.
 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

need translation?

Can someone tell me exactly what this code is doing? # # gnutest # # Test launch of ghostscript (gs) from a script # rm gnutest.ps # # ------- calculation that would generate file(s) to # be plotted with gnuplot would be placed here ----------- # gnuplot << \E-o-f2 set... (1 Reply)
Discussion started by: wmosley2
1 Replies

2. Programming

Swedish Character translation

Sorry if this been posted before. At the moment I'm having problem with the iscntrl() function. I need it to run a check on code entered into a Text Box, however I also need to allow the "Ö, ö" Swedish characters. The iscntrl() function seems to pick up the characters above as part of the... (0 Replies)
Discussion started by: rebelwassie
0 Replies

3. Shell Programming and Scripting

I need translation!

Someone give me info on this script. I put all the parts I do not understand in BOLD. Please someone explain what the parts in BOLD does/mean. Thanks! #!/bin/bash #Usage: cmdArgs.sh arg1 arg2 arg3 printf "The number of command line args is: $#\n" declare -i counter #Not strictly... (7 Replies)
Discussion started by: 801238429
7 Replies

4. UNIX for Dummies Questions & Answers

help --translation

I am reading the SANS security policy--.I want to translate the to Chinese.But I don`t understand a paragraph of the. It is :"Where SNMP is used, the community strings must be defined as something other than the standard defaults of "public," "private" and "system" and must be different from... (1 Reply)
Discussion started by: beijingzhzj
1 Replies

5. UNIX for Dummies Questions & Answers

AIX to HP-UX translation please

I have been looking up the allocated space, free space and the contents (raw, jfs, paging) of the logical volumes in AIX servers. I have been using lsvg and lsvg -l (server name). What is the HP-UX equivalent to that? I was given this command also so I would not have to type in each volume group... (2 Replies)
Discussion started by: compan023
2 Replies

6. AIX

Can't ping - IP translation issue?

Hello, Any help or advice on this would be greatly appreciated. I have a site-to-site VPN, across which data is synced between two CRM systems. The opposing side of this tunnel is a flat network (lets call it 201.200.156.xx/24) My internal network is a 192.168.0.xx/24 network, however before... (2 Replies)
Discussion started by: thruster9
2 Replies

7. IP Networking

Network address translation

How would one approach the problem of determining the NAT tables of a router without knowing the userid and password. The only password holder died. I know the internal ip address of the router is 192.168.2.1, and also ports 80 or 8080 and 3389 are open. (5 Replies)
Discussion started by: jgt
5 Replies
Text::Tabs(3pm) 					 Perl Programmers Reference Guide					   Text::Tabs(3pm)

NAME
Text::Tabs -- expand and unexpand tabs per the unix expand(1) and unexpand(1) SYNOPSIS
use Text::Tabs; $tabstop = 4; # default = 8 @lines_without_tabs = expand(@lines_with_tabs); @lines_with_tabs = unexpand(@lines_without_tabs); DESCRIPTION
Text::Tabs does about what the unix utilities expand(1) and unexpand(1) do. Given a line with tabs in it, expand will replace the tabs with the appropriate number of spaces. Given a line with or without tabs in it, unexpand will add tabs when it can save bytes by doing so (just like "unexpand -a"). Invisible compression with plain ASCII! EXAMPLE
#!perl # unexpand -a use Text::Tabs; while (<>) { print unexpand $_; } Instead of the "expand" comand, use: perl -MText::Tabs -n -e 'print expand $_' Instead of the "unexpand -a" command, use: perl -MText::Tabs -n -e 'print unexpand $_' LICENSE
Copyright (C) 1996-2002,2005,2006 David Muir Sharnoff. Copyright (C) 2005 Aristotle Pagaltzis This module may be modified, used, copied, and redistributed at your own risk. Publicly redistributed modified versions must use a different name. perl v5.12.1 2010-04-26 Text::Tabs(3pm)
All times are GMT -4. The time now is 03:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy