10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I am trying with the below Perl command to print the first field when the second field matches the given pattern:
perl -lane 'open F, "< myfile"; for $i (<F>) {chomp $i; if ($F =~ /patt$/) {my $f = (split(" ", $i)); print "$f";}} close F' dummy_file
I know I can achieve the same with the... (7 Replies)
Discussion started by: royalibrahim
7 Replies
2. Shell Programming and Scripting
Script for if characters from positions 7-15 are matching with characters from position 211-219 then replace all char from 211-219 with 9 space.
Total length of record is 420. Here is the specification of the data in file.
Position Field Data Type... (5 Replies)
Discussion started by: lancesunny
5 Replies
3. Shell Programming and Scripting
Hi,
A perl newbie here so pretty sure it's something simple. Trying to figure out how to count matches with perl pattern matching. The following script opens a text data file and finds lines containing
"PORT:" and I'd like to count how many of these are found.
Any ideas?
open(LOG,"<... (3 Replies)
Discussion started by: hdefjunkie
3 Replies
4. UNIX for Dummies Questions & Answers
Hi, I'm trying to find the position of a series of numbers within a large text file. The numbers are separated by spaces.
This works fine:
type Huge_File.txt | gawk "{print index($0,"255")}"
But this does not:
type Huge_File.txt | gawk "{print index($0,"188 028 239 160 016 190 137... (4 Replies)
Discussion started by: Lemming42
4 Replies
5. Shell Programming and Scripting
I need to process a file line-by-line using some value from a shell variable
Something like:perl -p -e 's/$shell_srch/$shell_replace/g' input.txt
I can't make the '-s' work in the '-p' or '-n' input loop (or couldn't find a syntaxis.)
I have searched and found... (4 Replies)
Discussion started by: alex_5161
4 Replies
6. Shell Programming and Scripting
Can we please modify this perl one-liner to print lines between pattern1 and pattern2 in a file?
Currently it prints lines till pattern2. (4 Replies)
Discussion started by: anand_bh
4 Replies
7. Shell Programming and Scripting
#!/usr/bin/perl
use Shell;
open THEFILE, "C:\galileo_integration.txt" || die "Couldnt open the file!";
@wholeThing = <THEFILE>;
close THEFILE;
foreach $line (@wholeThing){
if ($line =~ m/\\0$/){
@nextThing = $line;
if ($line =~ s/\\0/\\LATEST/g){
@otherThing =... (2 Replies)
Discussion started by: nmattam
2 Replies
8. UNIX for Dummies Questions & Answers
hi friends.
i want to create new file name depends upon user input value.......the format is "txt_VVVV.txt". is it possible?
#bin/ksh
typeset -i10 i = $1
case $i in
*)
fil = "txt_000"$i".txt"
;;
*)
fil = "txt_00" $i... (4 Replies)
Discussion started by: ilayans
4 Replies
9. Shell Programming and Scripting
When we give an input sequence , the program should match with the pattern and give the matches and mismatches in the output.
i will give you 2 small examples. if you cant get it pls let me know.
i will try to give a clear idea.
example 1:
$a=APPLE; # let it be a pattern... (0 Replies)
Discussion started by: srisha
0 Replies
10. Shell Programming and Scripting
in my file, i like to search for a string and if there is a match then i want to replace it with someother string(like in windows wordpad).
i only know how to search for a pattern.... but i dont know how to replace it..
and
1). i think it is there in unix grep or some other commends... if... (6 Replies)
Discussion started by: sekar sundaram
6 Replies