Search Results

Search: Posts Made By: sam05121988
1,749
Posted By sam05121988
for i in user1 user4 usern do grep -B2 "$i"...
for i in user1 user4 usern
do
grep -B2 "$i" file | sed 's/^/#/g'
grep "$i" file | sed 's/^/#/g'
grep -A1 "$i" file | sed 's/^/#/g'
done
2,675
Posted By sam05121988
if you have perl on solaris... perl -ne 'if...
if you have perl on solaris...
perl -ne 'if (/<name>(.*)<\/name>/) {print "$1";}' deploy.tmp
3,157
Posted By sam05121988
perl solution $ cat test2 11,aa,22,ss ...
perl solution


$ cat test2
11,aa,22,ss
12,ss,23,ff
11,aa,22,ss
12,ss,23,ff


Script and usage
$ perl drop_columns.pl
Usage: drop_columns.pl -d:<delim> -f:fields -file:filename

Script...
3,157
Posted By sam05121988
You don't need a script for that, can do it using...
You don't need a script for that, can do it using cut command
cut -d',' -f1 test1
cut -d',' -f1,3 test2
2,112
Posted By sam05121988
perl -ne '@arr = split(/\|/,$_,-1); ...
perl -ne '@arr = split(/\|/,$_,-1);
for($i=0;$i<@arr;$i++) {
next if $i =~ /^(5|7|8)$/ ;
$flag = 1 if ($arr[$i] eq "");
}
print join("|",@arr) if $flag;
' file.txt
Forum: Programming 05-25-2015
1,795
Posted By sam05121988
$vi ab.py prev_line_has_tag=False with...
$vi ab.py
prev_line_has_tag=False

with open('file2.xml','r') as f1:
for line in f1:
print("",line,sep='',end="")
if line.startswith("<!--"):
...
1,076
Posted By sam05121988
Input File $ cat abc Jane,group=A ...
Input File

$ cat abc
Jane,group=A
Bob,group=A
Bob,group=D
Joe,group=B
Bill,group=A
Cathy,group=C
David,group=A
David,group=B
Ed,group=A

Code

$ perl -e '
my $hash;
while(<>){...
2,882
Posted By sam05121988
$line = "whatever your want to print" printf...
$line = "whatever your want to print"
printf "$line" | perl -ne ' @x = split("",$_); print "$_\n" foreach(@x); '
2,882
Posted By sam05121988
just type perl -v on your command line if...
just type
perl -v
on your command line
if it gives output like this, you are good to use the command line provided by me in the other comment

perl -v

This is perl, v5.10.1 (*) built for...
2,882
Posted By sam05121988
if it's ok to use perl $ printf "abc def ...
if it's ok to use perl

$ printf "abc def ghi" | perl -ne ' @x = split("",$_); print "$_\n" foreach(@x); '
a
b
c

d
e
f




g
h
i
3,481
Posted By sam05121988
If you have or can have XML::Simplemodule...
If you have or can have
XML::Simplemodule installed

perl -MXML::Simple -e '
foreach (@ARGV) {
$x_in = XMLin("$_");
print "$x_in->{name}";
}
' *.xml$ cat b.xml
<?xml version="1.0"...
3,597
Posted By sam05121988
Unable to unlink files perl
Hi,

I have a dir and some files as below (all have full perm)


drwxrwxrwx 2 sam sam 4096 Aug 8 04:31 /home/sam/test

$ ll /home/sam/test
-rwxrwxrwx 1 sam sam 0 Aug 8 04:31...
3,907
Posted By sam05121988
Perl combine multiple map statements
I have a file like

file.
file.TODAY.THISYEAR
file.TODAY.LASTYEARI want to substitute the words in caps with their actual values so that output should look like
file.140805
file.140805.2014...
2,581
Posted By sam05121988
use absolute path of isql in your shell script
use absolute path of isql in your shell script
7,190
Posted By sam05121988
Wow!!!, thanks to all of you for your responses. ...
Wow!!!, thanks to all of you for your responses.
I got what I wanted :b:
7,190
Posted By sam05121988
Insert a value in a pipe delimited line (unsig sed,awk)
Hi,

I want to insert a value (x) in the 3rd position of each line in a file like below

a|b|c|d|1
a|b|c|d
a|b|c|d|e|1
a|b|cso that output file looks like

a|b|x|c|d|1
a|b|x|c|d...
2,140
Posted By sam05121988
if you are on a linux system this will definetly...
if you are on a linux system this will definetly work in bash, for unix you will need to test in ksh

#!/bin/bash

Date=`date "+%Y%m%d"`

for fl in /prd/pdw/Backup/*${Date}*
do
...
3,556
Posted By sam05121988
Edit a file in perl
Hi,

I have a file like
$ cat abc
HDR XXX
content XXX
content YYY
content XXX
content YYY
content XXX
content YYY
TRL YYYI want to replace the lines staritng with HDR and TRL
For this I...
1,210
Posted By sam05121988
Thanks again
Thanks again
1,210
Posted By sam05121988
Thanks KlashXX Asking a little more help,...
Thanks KlashXX

Asking a little more help, can you please explain the below snippet

my $line;
foreach (<FA>)
{ #getting rid of TAILER in fileA
print TMP $line if $line;...
1,210
Posted By sam05121988
Efficiently altering and merging files in perl
I have two files

fileA
HEADER LINE A
CommentLine A
Content A
....
....
....
TAILER AfileB
HEADER LINE B
CommentLine B
Content B
....
....
....
TAILER BI want to merge these two...
3,842
Posted By sam05121988
Thanks Don for the fix :)
Thanks Don for the fix :)
3,842
Posted By sam05121988
Thanks Pikk45 :)
Thanks Pikk45 :)
3,842
Posted By sam05121988
Cron doesn't run job in background
Hi,

First of all merry christmas and Happy holidays to all :D

My situation is as below,
When a backup job runs on a mainframe server, it creates a 0byte file on a network drive which is...
2,952
Posted By sam05121988
figured out the solution myself, thanks for your...
figured out the solution myself, thanks for your help
Showing results 1 to 25 of 82

 
All times are GMT -4. The time now is 12:16 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy