Programming :: Substitute 2 Character Country Abbreviations To 3?
Dec 20, 2010
I have a list of 2 character country abbreviations used in the Maxmind GeoCountry database that I need to convert to the standard 3 character country abbreviation ISO 3166-11 format. I could have a long list of sed substitute statements for each country.
Code:
sed "s/US/USA/g" <file>
Is their a more elegant way to do this? Maybe an array of some sort? This substitution will be used in a bash script.
View 4 Replies
ADVERTISEMENT
Mar 30, 2010
I have the following file:
Code:
1 line
...
49 test test=AA:AA:AA:AA:AA=0
I need to substitute on the line number 49, all text until =. I have used the following, but with no actual result.
sed -re '49s/^.+=//' file
and
sed -e '49s/.*[=]//' file
View 5 Replies
View Related
Apr 21, 2010
i want to substitute in a file what it comes with "(" character to "('". i have tried to do it with gsub but it doesn`t go well with regular expression.
View 4 Replies
View Related
Mar 25, 2011
I need something to make a script that will search some logs and extract IP hits from one country only. Let's say UK. I guess I need to use GeoIP or some database. I just need a very simple bash, perl, php script that will do this job. Just search threw logs (apache) and then give me number of hits found from UK.
View 5 Replies
View Related
Mar 11, 2010
I have this PHP Program I have been hobbying for years. Started in old PHP3 early PHP4. So with the newer PHP, things are starting to break! I have this string:
session_is_registered('UserID')
And I need to convert to this:
isset($_SESSION['UserID'])
in more than 200 scripts in my directory. I have been toying with perl (in a copy of the dir of course in case I really screw things over, lol) but am not gettig too far. The new code needs to swap ( ) for [ ] and i'm just all hung up! I am getting lost in Perl, I have this, but it does not substitute so I am missing something:
perl -i.bak -pe "s/session_is_registered('UserID')/isset(\$_SESSION['UserID'])/g" *.php
View 7 Replies
View Related
Mar 27, 2010
1.What character instructd the shell to interpret a special character as an ordinary character?
2.What directory contains some of the utilities available on the system in the form of binary files?
3. What command is used to search the location of a utility?
4. What command is used to instruct the editor to write the file and quit the editor?
5. What key quits the more utility and displays the shell prompt?
6. What command starts a child shell as the super user, taking on root's identity and environment?
7. Which wildcard characters can be used for searching all the files in the system that start with "A"?
8. The user name or login name of the super user is????
[Code]....
View 10 Replies
View Related
Mar 29, 2010
i have a PHP program, it encompasses about 200 scripts. Years ago, it was rewritten by another programmer to be multi-lingual, but the multi-lingual attraction of it never took off. Now that I am the only maintainer, trying to reuse what I have for code is quite difficult. If I look at one script, I see items like
_HEADER_TEXT_ERROR_4
_TABLE_ROW_SIZED_FORMAT
_ERROR_SELECT_RADIO_MAIN
All of these (and many more) are found in a "main.php" file that sort of go like this:
DEFINE _HEADER_TEXT_ERROR_4 "You Entered a Bad Value";
DEFINE _TABLE_ROW_SIZED_FORMAT "Last Name";
DEFINE _ERROR_SELECT_RADIO_MAIN "Make Your Selections";
What I would like to do is have something that says FOR all files in this directory, when you find something that starts with _, find that value in main.php and substitue what is inside the quotes for that value. Sort of unwriting all this multi-lingual stuff. I can format how I would do it if it was all stored in MySQL, but doing it from bash has me perplexed.
View 11 Replies
View Related
Jan 17, 2009
I have an old-address-list file which is having around 1500 entries. I need to convert this addresses in to a specific format.
The old-address-list file>
# cat old-address-list-file
dn: CN=Muhammad Hadhi K.M,OU=IT Dept,OU=Example Company H.O,DC=example,DC=com
cn: Muhammad Hadhi K.M
[code]....
View 6 Replies
View Related
May 28, 2011
Kernel 2.6.21.5, Slackware 12.0top: procps 3.2.7Hi:Running top, I read, in the summary area,
Code:
root@darkstar:~# top
........
[code]....
View 3 Replies
View Related
Jun 27, 2010
I have a string like this "/home/test/filename.txt" and i want to delete all character after the last "/". how to do that using sed or awk.
View 5 Replies
View Related
Nov 3, 2010
I was reading Kernighan Ritchie book chapter 4 which deals with character pointers.I am not able to understand following different type of declarations
Code:
char aname[][15] = { "Illegal month", "Jan", "Feb", "Mar" };
char amessage[] = "now is the time";
[code]...
View 1 Replies
View Related
Oct 23, 2010
i am compiling the following program in linux. it's in c language. after the compilation with gcc when i run the executable file. it asks for input. but when i enter a name. i prints "Segmentation fault" and then terminate the program. can you please help me.
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <unistd.h>
[code]....
View 1 Replies
View Related
Feb 24, 2010
which is the simplest way to have first and last character cropped out from a string? Something simpler than
Code:
echo $STRING | cut -b 2- | rev | cut -b 2- | rev
View 6 Replies
View Related
May 11, 2011
I have a file with one line. I want to check whether the first character is TAB or space, how can i do this.? using "cut" wont as it "bypasses the tab and space characters"
View 3 Replies
View Related
Apr 22, 2011
I am trying to check if the 9th character in a file on each line is a v and if so, then print the first word. I've tried a number of variations and am stuck !If it's possible to also check if character position 1 begins with a s in the same awk, that would make it cleaner instead of using egrep.
egrep '^s' file | nawk '{virtual=substr($0,9,1); if ($virtual=="v") {printf "%s", $1}}'
nawk: illegal field $(e)
input record number 1
source line number 1
View 13 Replies
View Related
Aug 2, 2010
I believe I have unwanted ' characters left in a 9 element character array that are causing subsequent operations with it to fail. I see wildly differing views on the web on the proper way to flush 'em. It's clearly not as simple as it would appear at first sight. What's currently the best (or else "least deprecated") method?
View 5 Replies
View Related
Feb 12, 2010
I am loading variables for cXtXdXsX disk names into a script, and at present I have only accounted for there being 3 characters from c to t. I need to change it to a variable recognition so that it can count any number of charcters such as c1t , c10t , or c100t.
I can then take that information and use it with the following string to strip off the lead characters so as to make the 3 in $substr either a variable or redirect to multiple occurrences of raw based on the count returned.
sub raw {
$substr = substr ($_, 3);
$raw1 = substr ($substr, 0, -4);
$raw = lc($raw1);
}
how to count from the c to the t inclusive so I get 3, 4, 5, etc ...
View 9 Replies
View Related
Jan 19, 2011
how to replace last character string. For example
$>export T1=abcde
$>export T2=xyz
how to get result abcdxyz?
View 10 Replies
View Related
Jul 25, 2011
I have a string as below
LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined
Want the above string to be modified as
LogFormat "%h %l %u %D %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined
inserting %D after %u in the string
View 3 Replies
View Related
Jan 8, 2010
I am trying to create a table T having a field F which should be able to store variable-length sequences of "unsigned" characters (8bit values ranging from 0 to 255 (not including 0, including 255)).(MAX_LENGTH) is not working, as it seems to want sequences of 8bit values ranging from 0 to 127 (thus "signed" characters).Can anyone help me by pointing out if there is a type suited for my needs (or if such a type does not exist)?For those familiar to C programming and working with the MySQL client library, I should be able to (successfully) do something along the lines of:
Code:
unsigned char value[] = { 'H', 'E', 'L', 'L', 'O', -1, -128, 'W', 'O', 'R', 'L', 'D' };
unsigned char query[255];
[code]....
View 3 Replies
View Related
Jun 22, 2010
i have the following:
Quote:
echo %host%|sed "$s/.$//"
this would remove the Last character of the value assigned to the %host%. for example if my value is: abcd i get abc. but i am not able to assign the output. for example when i do
Quote:
set k=`echo %host%|sed "$s/.$//"`
after doing echo %k i get no output at the command prompt...!! whereas when i just type:
Quote:
echo abcd|sed "$s/.$//"
at the command prompt i get abc. maybe some other ways to Remove the Last character...?
View 13 Replies
View Related
Apr 7, 2011
I have the following string:"My dog spot(page 1)". I want just "My dog spot". How do I do this in SQL Server?
View 2 Replies
View Related
Mar 31, 2010
I've a problem with character device mounting. I've a character device module code. Here is the code
Code: /* chardev.c: Creates a read-only char device that says how many times
* you've read from the dev file
*/
#if defined(CONFIG_MODVERSIONS) && ! defined(MODVERSIONS)
#include <linux/modversions.h>
#define MODVERSIONS
[Code]...
View 1 Replies
View Related
Jul 12, 2010
i was trying to access the address of the character pointer it gives me the values stored in the variable.
Code: #include<iostream>
using namespace std;
int main()
{
char *i;
[Code]....
why is my code not giving the address of the variable i when it is a character pointer.
View 2 Replies
View Related
Jun 23, 2011
Im trying to read a file in c++ and search for particular character for example if this is a list that I have:
Alice
Bob
David
[code]....
if the input is D, it should give David, if its B, gives bob. so in this case, meaning it reads the first character of every line. but if possible I want to make this dynamic so the user can specify which character position he is looking for, so in case he is looking for R as character index 3 in all lines, it should give Charlie. but the problem is, it does now recognize , besides, I do not know how to specify the character position in each line.
here is my code
Code:
#include <iostream>
#include <fstream>
#include <cstring>
[code]....
View 1 Replies
View Related
Jun 25, 2010
I have the following command that greps "/etc/cron.allow" and displays the following 9 lines of $file grep -A 9 "/etc/cron.allow" $file On the other hand I would like to grep a file for a certain text display the next couple of lines and stop when i hit a specified word or blank or pattern.Basically I would like my grep to end when the shell hits a blank, certain key word or pattern specified in command.
View 7 Replies
View Related
Aug 18, 2010
i have problem in java. how to convert string array to character. e.g string a[]={"ab","abc","abd","ag"}; what will be the character array ?
View 3 Replies
View Related
May 15, 2010
As you know, in C++ you can use setfill(char c); and setwidth( int length) to fill a line of a character.
It's line making a line of a character for output
Code:
NAME DEPARTMENT LOCATION
==========================================
Pete R&D Chicago
...
==========================================
As you see, a line of a '=' character drawn to output.
I'm wondering, how can I draw this line in C using printf() to format?
( no loop or repetiton )
View 8 Replies
View Related
Jun 15, 2011
I need some software that will check .xml file and tell me which character is malformed in 'utf-8'. I am using perl for some parsing.
View 2 Replies
View Related
Oct 3, 2010
I have a set of files containing DNA or amino acid sequences from various organisms:
Code:
>14432|LGIG|186221
--MISVLAMA-NRITAAEKR
>14432|CAP1|21057
MVRVNVLADALKSI-TAEKR
>14432|HROB|156827
--RMNVLADALXSIC?AEKR
>14432|NVEC|159589
-VRVNVLN-ALNSICNAEX-
[Code]...
Can anyone help me get the position of the first and last non-missing data characters (while allowing missing data characters in the middle of the sequence)? I'm sure it is a simple sed or awk command but I can't figure it out. I think I can produce the output file I want once I have figured those commands out.
My ultimate goal is to write a script that can make composite sequences from two or more non-overlapping sequences (e.g., the two sequences from NEOM). I may also want to merge sequences that partially overlap (e.g., those from TEST) but that would complicate things. Is this a logical first step for such a script or would you do it differently?
View 10 Replies
View Related