Sponsored Content
Top Forums Shell Programming and Scripting cut certain characters for each line in a file Post 302567095 by jimmy_y on Saturday 22nd of October 2011 07:21:40 AM
Old 10-22-2011
Power cut certain characters for each line in a file

Hi Everyone,
i have a file 1.txt
Code:
<a><a"" dd>aaaaauweopriuew</f><">!(^)!</aa></ff>
<a><a"" dd>bbbbbuweopriuew</f><">!(^*)!</aa></ff>

i know i can use
Code:
perl -p -i -e "s/>aaaaa/aa/g" 1.txt
perl -p -i -e "s/>bbbbb/bb/g" 1.txt

to acheive only keep the first two characters of the five characters, so the output is
Code:
<a><a"" dd>aauweopriuew</f><">!(^)!</aa></ff>
<a><a"" dd>bbuweopriuew</f><">!(^*)!</aa></ff>

but image this 1.txt has many lines, i cannot do this perl -p -i -e one line each.
any awk, sed, or other shell can do? Smilie

Please advice.

Thanks
Regards,

Last edited by radoulov; 10-22-2011 at 08:42 AM.. Reason: Code tags!
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

cut first 4 characters from a line

Please let me know how to cut first four characters from a line in UNIX after grepping the file.. (5 Replies)
Discussion started by: kaushikraman
5 Replies

2. Shell Programming and Scripting

how to cut first 3 characters of each line in a file

Hi Friends I have a file like sample1.txt ------------ 10998909.txt 10898990.txt 1898772222.txt 8980000000000.txt I need to take first 3 characters of each line in a file and i need to print it ' like loop 109 108 189 898 (7 Replies)
Discussion started by: kittusri9
7 Replies

3. Shell Programming and Scripting

cut 1st 2 characters off all line1st in file

I know this sounds simple, but I have a logfile with > something > something_else > another_entry ... how do I cut the first 2 characters off the left side? I tried to use cut -c 1-2 somefile > someotherfile but that just cut gave me the 2 left characters, I want to cut those out... (2 Replies)
Discussion started by: unclecameron
2 Replies

4. Shell Programming and Scripting

How can i cut first line of a file

i want to cut first line of a file and use it.It should remove that line from file content.Plz help me (7 Replies)
Discussion started by: arghya_owen
7 Replies

5. Shell Programming and Scripting

cut between characters of a file

Hi All, Need to convert file names to upper case using tr command in Unix. In a folder -> /apps/dd01/misc there are two files like: pi-abcd567sd.pdf pi-efgh1.pdf The output of should be like: pi-ABCD567SD.pdf pi-EFGH1.pdf I have used the command to work as below: for f... (3 Replies)
Discussion started by: a1_win
3 Replies

6. Shell Programming and Scripting

Need to cut first 21 and 32-25 characters from file

Guys, can you help me in doing cut first 21 and 32-35 characters from file. I tried with cut -c to cut first 21 characters ,It is succeeded. But i need both first 21 and 32-35. (1 Reply)
Discussion started by: mohan_xunil
1 Replies

7. AIX

How to cut a flat file according to a certain number of characters?

hello everybody i am looking for a shell to cut a flat file (with a long unique line) according to a certain number of characters and redirect every result to an output file. here is an example MyFile : 12 3 456 12 3 456 12 3 456 ..... and i took every 9-characters including BLANKS... (6 Replies)
Discussion started by: fastlane3000
6 Replies

8. Shell Programming and Scripting

Cut last 13 characters and take the rest of the file name

Hi, I would like to cut last 13 characters of a file name and take the rename the file name as follows: Input: A.DAT20110517033732 Output: A.DAT I have tried the following command and cut last 13 characters. echo A.DAT20110517033732 | awk '{print substr($0, length($0)-13)}' ... (3 Replies)
Discussion started by: pyaranoid
3 Replies

9. Shell Programming and Scripting

cut the variable from the line and use it to find the file and read the content of that file

Hi, I am working on one script..I am having files in the below format file 1 (each line is separated with : delimeter) SPLASH:SPLASH:SVN CIB/MCH:MCH:SVN Now I want from file 1 that most left part of the first line will store in... (6 Replies)
Discussion started by: rohit22hamirpur
6 Replies

10. Shell Programming and Scripting

Cut the first 100 characters of file

Hello all, I have a file and would like to cut the first 100 characters of the first line. I tried it with the ‘cut’-command: cut –c100- $file > $file.tmp But this does not work, because it will cut the first 100 characters of each line. But I need to cut them only from the beginning of... (6 Replies)
Discussion started by: API
6 Replies
Locale::Codes::LangFam(3pm)				 Perl Programmers Reference Guide			       Locale::Codes::LangFam(3pm)

NAME
Locale::Codes::LangFam - standard codes for language extension identification SYNOPSIS
use Locale::Codes::LangFam; $lext = code2langfam('apa'); # $lext gets 'Apache languages' $code = langfam2code('Apache languages'); # $code gets 'apa' @codes = all_langfam_codes(); @names = all_langfam_names(); DESCRIPTION
The "Locale::Codes::LangFam" module provides access to standard codes used for identifying language families, such as those as defined in ISO 639-5. Most of the routines take an optional additional argument which specifies the code set to use. If not specified, the default ISO 639-5 language family codes will be used. SUPPORTED CODE SETS
There are several different code sets you can use for identifying language families. A code set may be specified using either a name, or a constant that is automatically exported by this module. For example, the two are equivalent: $lext = code2langfam('apa','alpha'); $lext = code2langfam('apa',LOCALE_LANGFAM_ALPHA); The codesets currently supported are: alpha This is the set of three-letter (lowercase) codes from ISO 639-5 such as 'apa' for Apache languages. This is the default code set. ROUTINES
code2langfam ( CODE [,CODESET] ) langfam2code ( NAME [,CODESET] ) langfam_code2code ( CODE ,CODESET ,CODESET2 ) all_langfam_codes ( [CODESET] ) all_langfam_names ( [CODESET] ) Locale::Codes::LangFam::rename_langfam ( CODE ,NEW_NAME [,CODESET] ) Locale::Codes::LangFam::add_langfam ( CODE ,NAME [,CODESET] ) Locale::Codes::LangFam::delete_langfam ( CODE [,CODESET] ) Locale::Codes::LangFam::add_langfam_alias ( NAME ,NEW_NAME ) Locale::Codes::LangFam::delete_langfam_alias ( NAME ) Locale::Codes::LangFam::rename_langfam_code ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangFam::add_langfam_code_alias ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangFam::delete_langfam_code_alias ( CODE [,CODESET] ) These routines are all documented in the Locale::Codes::API man page. SEE ALSO
Locale::Codes The Locale-Codes distribution. Locale::Codes::API The list of functions supported by this module. http://www.loc.gov/standards/iso639-5/id.php ISO 639-5 . AUTHOR
See Locale::Codes for full author history. Currently maintained by Sullivan Beck (sbeck@cpan.org). COPYRIGHT
Copyright (c) 2011-2013 Sullivan Beck This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.18.2 2013-11-04 Locale::Codes::LangFam(3pm)
All times are GMT -4. The time now is 11:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy