If any one can help me with changing the UIDs only without changing the format of the file.
---------- Post updated at 01:27 AM ---------- Previous update was at 01:03 AM ----------
why can't we search a string in a file and substitute with a string from another file.
Why is it we have to make a regular expression containing Name / Uid.
why can't a string be searched line by line in a file without any dependency.
Last edited by shahid1632; 11-30-2015 at 03:40 PM..
Reason: not working
If any one can help me with changing the UIDs only without changing the format of the file.
---------- Post updated at 01:27 AM ---------- Previous update was at 01:03 AM ----------
why can't we search a string in a file and substitute with a string from another file.
Why is it we have to make a regular expression containing Name / Uid.
why can't a string be searched line by line in a file without any dependency.
I am sorry the Perl script is of no use to you. If you post in which way it failed I might be able to know why.
The answer to all your "why(s)" is this. I do not know how your real data looks like, I can only go by what you have posted, and as I have shown you in post #7,
according to the information you have given, the result is as requested. You do not want to allow the substitution to occur in lines that it is not intended for, inadvertently.
If you think that's the problem, please, just remove the extra condition:
Change if($blocks[1] and $blocks[0]=~/^Name|^Uid/){ to if($blocks[1]){
Quote:
If any one can help me with changing the UIDs only without changing the format of the file.
Please, show us how the format is changed. My script does not change any format. It leaves spaces and symbols and newlines as found.
To reply to your three "why"s:
1) !t can be and has been done; any of the solutions provided does exactly this.
2) For safety reasons. If you're absolutely sure there won't be any false positives, the name/uid check can be dropped.
3) see above.
As the solutions provided DO work when tested locally, I suspect your file has unusual structures, e.g. hidden characters like (but not limited to) the DOS <CR> (0x0D, \r, ^M) line terminators.
Thanks all of you, but i found a simple solution to my problem :
Firstly I added
to all the rows in the excel file X. Then made a text file X.
Then made a script myscript and executed ./myscript
Hi shahid1632
You never mentioned before that file X was an excel file. If this means that it came from a msdos world, your file X does need to have the hidden \r removed. Before using it, it should be ran through something like:
Now you can use file patternsX with any of the scripts previously given to you.
Concerning your "found" solution:
Quote:
You do not need the g at the end of the sed expression, unless you expect column 1 of file 'X' to appear several times in the same line in file name Y
Also, the only way that it might have worked is if you manually created an entry for each of the 1000 patterns in file X, which begs the question why not to manually do the replacement in file Y. It does not make any sense to fabricate 1000 shovels to dig a 1000 holes.
Sorry, Its my fault. I didn't told you that
the file X, contains many occurrences of column 1 value.
Second, The file X was a text file which was manually created by copying the contents from excel file.
Third, as you must be aware that in excel there is an option of dragging the contents to the last row so there was negligible effort involved in making the mysript from already file X which was in excel.
Thanks to all of you once again.
For the sake of other readers you can wrap up by posting the perl script once again.
Hello.
System : opensuse leap 42.3
I have a bash script that build a text file.
I would like the last command doing :
print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt
where :
print_cmd ::= some printing... (1 Reply)
Hi, all, I have a file that looks like:
## XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
## YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
#AA AB AC AD AE AF AG AH AI AJ AK AL
20 60039 60039 ... (5 Replies)
How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address
and column 3 contains “cc” e-mail address to include with same email.
Sample input file, email.txt
Below is an sample code where... (2 Replies)
Hi all.
I have a .txt file that I need to sort it
My file is like:
1- 88 chain0 MASTER (FF-TE) FFFF 1962510 /TCK T FD2TQHVTT1 /jtagc/jtag_instreg/updateinstr_reg_1 dff1 (TI,SO)
2- ... (10 Replies)
Hi,
I'm dealing with an issue and losing a lot of hours figuring out how i would solve this.
I have an input file which looks like this:
('BLABLA +200-GRS','Serviço ','TarifaçãoServiço','wap.bla.us.0000000121',2985,0,55,' de conversão em escada','Dia','Domingos')
('BLABLA +200-GRR','Serviço... (6 Replies)
Hi all,
I have this text file containing 9 columns separated by space. The 8th columns contains the numbers.
C1 C2 C3 C4 C5 C6 C7 C8 C9
er rt yt gh iu nk il 0.07 xs
yt lr ty bg iu zk nh 0,0005 lt
...etc.
I want to replace the comma with full stop only in 8th coloumn.
the output... (8 Replies)
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
Hi All,
I have working (Perl) code to combine 2 input files into a single output file using the join function that works to a point, but has the following limitations:
1. I am restrained to 2 input files only.
2. Only the "matched" fields are written out to the "matched" output file and... (1 Reply)
Hi Friends,
Can any of you explain me about the below line of code?
mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`
Im not able to understand, what exactly it is doing :confused:
Any help would be useful for me.
Lokesha (4 Replies)