Search Results

Search: Posts Made By: pravin27
1,645
Posted By RudiC
How aboutcase "$(wc -c <file)" in 0) echo empty...
How aboutcase "$(wc -c <file)" in 0) echo empty file;; 1) echo file with null record;; *) echo file with data;; esac
It would work on the given examples, but fail if a (non-*nix-text) file with a...
3,148
Posted By RudiC
With the assumptions: - not too many lines in...
With the assumptions:
- not too many lines in "allpath.txt",
- not too many files found,
- bash being used,
wouldn't this do?awk '
FNR == NR {R[$1] = $2
next
...
2,693
Posted By RudiC
As you can see, you have to go the extra mile to...
As you can see, you have to go the extra mile to achieve what you intended, and the eval has some caveats tagged to it. In recents shells, this could be done way easier using arrays:

DBname=($@)...
56,429
Posted By bakunin
You already have been given very good advice...
You already have been given very good advice here, so there is little for me to add - which is why i can as well quit pretending to be helpful and start to outright annoy you:

i think you tackle...
1,017
Posted By MadeInGermany
A bit altered coding: awk '{key=$1FS$2;...
A bit altered coding:
awk '{key=$1FS$2; a[key]=((key in a) ? a[key]","$3 : $3)} END {for (key in a) {print key, a[key]}}' testfile
2,374
Posted By MadeInGermany
@pravin27, didn't the previous post say that...
@pravin27, didn't the previous post say that SQLite and XML should match on the file type=contents not name?

The following pipes the output of a simple find command into a while loop that does the...
2,050
Posted By RudiC
You can't import shell variables into awk the way...
You can't import shell variables into awk the way you do in above post. Please read man awk and/or many threads in here about how to use the -v option to pass variables to awk.

In your case, with...
2,241
Posted By Skrynesaver
Hi Pravin, That will work however, while it...
Hi Pravin,

That will work however, while it will use less memory than a hash, it will use a lot more cycles. you are grepping through the (potentially large array) for every line of the file.
...
800
Posted By RudiC
Try alsoawk '{T[int(($1-1)/70)] = $1} END {for (t...
Try alsoawk '{T[int(($1-1)/70)] = $1} END {for (t in T) print T[t]}' file
69
139
210
345
418
490
492
1,030
Posted By Don Cragun
You mean something like: grep -Ff "File...
You mean something like:
grep -Ff "File Containing Pattern List A" "sample input text file" | grep -Ff "File Containing Pattern List B"
10,256
Posted By drl
Hi. I keep a number of perl modules local to...
Hi.

I keep a number of perl modules local to my home, not requiring the package manager. I generally don't put anything into /bin, /user/bin, etc., unless it is in the repositories. For many...
752
Posted By CarloM
It would be a lot easier to see if you indented...
It would be a lot easier to see if you indented your code.
872
Posted By RudiC
That's because the second time you (recursively)...
That's because the second time you (recursively) call function one, the else branch of if [ "$name" == "Sam" ]; will be taken.

BTW, you have a 16 bit char (0x 3000000, UTF8: 0xE3 0x80 0x80) in...
1,437
Posted By Akshay Hegde
awk 'x[$1,$2,$3,$4,$5]++{$1=$2=$3=$4=$5=""}1'...
awk 'x[$1,$2,$3,$4,$5]++{$1=$2=$3=$4=$5=""}1' FS=, OFS=, infile
1,472
Posted By Don Cragun
You could do this with awk, but it really isn't...
You could do this with awk, but it really isn't the right tool for this job.

The following seems to do what you want and should work on AIX:
#!/bin/ksh
file="ABCD_XYZ_20130302223203.xml"...
5,389
Posted By Scrutinizer
Hi, try: date --date="$(date +%Y%m15) 1 month...
Hi, try:
date --date="$(date +%Y%m15) 1 month ago" +%Y%m

This behavior occurs, because februari 30 does not exist. So it is best to use the middle of the month to calculate the previous month..
...
1,379
Posted By Scrutinizer
Hi Pravin, I could have used any file descriptor,...
Hi Pravin, I could have used any file descriptor, but I used 3 because 0,1 and 2 are taken by stdin, stdout and stderr. At the bottom of the loop I am redirecting file descriptor 3 to take its input...
1,379
Posted By Scrutinizer
@LeftoverStew, tt is a bit more complicated than...
@LeftoverStew, tt is a bit more complicated than that. A link in the same directory, means making the link to the file name only (without the path). Also, there are all sorts of error condition that...
2,667
Posted By ctsgnb
xargs -n1 <yourfile
xargs -n1 <yourfile
867
Posted By Scrutinizer
Q1: Given these variables: A="a b c d e f g 1...
Q1:
Given these variables:
A="a b c d e f g 1 2 3 4 5"
B="c 3"
You could try:

C=
for i in $A; do
for j in $B; do
if [ "$i" = "$j" ]; then
continue 2
fi
done
C="$C$i...
1,051
Posted By Chubler_XL
How about: my $file =...
How about:

my $file = "$WORK_DIR/tmpdata.asc";

open my $info, $file or die "Could not open $file: $!";
my %line;
local @ARGV = ($file);
my @temps;

while ( <$info> ) {
my $x1 =...
1,956
Posted By Akshay Hegde
One more way to get expected output $ cat...
One more way to get expected output

$ cat <<eof | awk 'gsub(/[[:alpha:]]|[[:punct:]]/,x)'
n<>the<>96427210 861521305 123257583
n<>obj<>79634223 861521305 79634223
n<>nmod<>68404733 861521305...
2,301
Posted By Chubler_XL
Parameter number 5 of localtime() is month number...
Parameter number 5 of localtime() is month number (0 for Janurary, 1 for Feburary ... 11 for December). So we need to convert the input string from a 3 character string (Jan, Feb, etc) to and...
2,588
Posted By jim mcnamara
In CarloM's very good answer - the >| is a POSIX...
In CarloM's very good answer - the >| is a POSIX required shell redirection operator - it overrides the noclobber option. You seldom see it in posts on this forum.

Shorthand for truncating a file...
2,588
Posted By CarloM
There's a few ways: remove or rename the...
There's a few ways:

remove or rename the old file.
unset noclobber (and set it back after).
force redirection using script >| file.
Showing results 1 to 25 of 66

 

Featured Tech Videos

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