Sponsored Content
Top Forums Shell Programming and Scripting looking for files and modify if size matches Post 302167812 by viko on Friday 15th of February 2008 02:07:36 PM
Old 02-15-2008
looking for files and modify if size matches

hi there.

I'm at SunOS 5.9

At my new job i'm using UNIX, and it's my first time.

i'm trying to make a script for:

-find files with a name passed to it as parameter
-compare results with file size passed as parameter too
-when comparison's true --> move file
-if not--> make nothing

well, i'll have prevent too similer name-size files. but i can solve that later.


my trouble now is in spliting string with awk. i can't understand why it doesn't

work


name=`find $CLL_DAT -name "$1*" -print`;
lines=`awk 'END { print NR }' $name`
echo "$lines";
if [ "$lines" = "$2" ];
then
echo "here i'll do what i have";
else
echo "ERROR $name";
fi


this is working, but i need to expand string catched by find, into 'n' strings,

and make things for all of them.


name=`find $CLL_DAT -name "$1*" -print`;
awk '{n=split($name,names," ")}'#########################i don't know how to make work this split function
flag=0

for (( i = 0 ; i <= n; i++ ))
do
lines=`awk '{END { print NR }}' ${names[$i]}`
echo "$lines"
if [ "$lines" = "$2" ];
then
if ["$flag" = 1];
then
echo 'two files matches'
exit
fi

flag=1
name=${names[$i]}
echo 'matches'
else
echo "don't matches"
fi
done
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Comparing two files and noting matches

I have two files. One contains names and another file (66 MB, ASCII format) contains details of persons. How do I compare the names in the first file with the second file and write the matches to a third file. I would prefer this to be solved in UNIX or VB. Thanks. (2 Replies)
Discussion started by: augustinep
2 Replies

2. Solaris

Modify the size of parttion under solaris

:( Hello! is there a tool like partition magic under solaris 9 to modify the size of the partitions. I do not manage to install patches because I do not have any more a place in the partition root. Thank you (1 Reply)
Discussion started by: toufik
1 Replies

3. Shell Programming and Scripting

bash script working for small size files but not for big size files.

Hi, I have one file stat. Stat file contents are as follows: for example. H50768020040913,00260100,507680,13,0000000643,0000000643,00000,0000 H50769520040808,00260100,507695,13,0000000000,0000000000,00000,0000 H50770620040611,00260100,507706,13,0000000000,0000000000,00000,0000 Now i... (1 Reply)
Discussion started by: davidpreml
1 Replies

4. Shell Programming and Scripting

Looking for a string in files and reporting matches

Can someone please help me figure out what the command syntax I need to use is? Here is what I am wanting to do. I have hundreds of thousands of files I need to look for a specific search string in. These files are spread across multiple subdirectories from one main directory. I would like... (4 Replies)
Discussion started by: btrotter
4 Replies

5. UNIX for Advanced & Expert Users

Command similar to "touch" for modify File size

Hi All, I'm trying to find a command like similar to "touch" which would let me change the file size property. For ex: I have a file of size 1MB using the command i would like to set/update the size something like 1KB. Is it possible? Is there any such command which would accomplish this... (3 Replies)
Discussion started by: sriharshareddyk
3 Replies

6. UNIX for Advanced & Expert Users

how to modify font size and type from script

I need to print different lines in different font types and sizes to the terminal window from csh script. I can easily change font color and print characters in bold or underline, but cannot figure out a way to change font. Any help is greatly appreciated.:confused: (3 Replies)
Discussion started by: helido
3 Replies

7. Shell Programming and Scripting

how to modify ramdisk size,kinda urgent !!!

Hi all, I wanted to know how to modify the size of the ramdisk? I mean am manipulating a live cd ,for which the file am manipulating is within a ramdisk now due to size constraints i am unable to play around with some stuff.... currently the size of the ram disk is 64M... I would like to... (1 Reply)
Discussion started by: wrapster
1 Replies

8. Solaris

Modify pset size

I 'm unable to modify pset size configuration. # poolcfg -c 'modify pset pset-app (uint pset.size = 16 )' poolcfg: put property pset.size failed: Bad parameter supplied (2 Replies)
Discussion started by: fugitive
2 Replies

9. Shell Programming and Scripting

Comparing the matches in two files using awk when both files have their own field separators

I've two files with data like below: file1.txt: AAA,Apples,123 BBB,Bananas,124 CCC,Carrot,125 file2.txt: Store1|AAA|123|11 Store2|BBB|124|23 Store3|CCC|125|57 Store4|DDD|126|38 So,the field separator in file1.txt is a comma and in file2.txt,it is | Now,the output should be... (2 Replies)
Discussion started by: asyed
2 Replies

10. Shell Programming and Scripting

Compare 2 files and print matches and non-matches in separate files

Hi all, I have two files, chap.txt and complex.txt. chap.txt looks like this: a d l m r k complex.txt looks like this: a c d e l m n j a d l p q r c p r m ......... (7 Replies)
Discussion started by: AshwaniSharma09
7 Replies
IGAWK(1)							 Utility Commands							  IGAWK(1)

NAME
igawk - gawk with include files SYNOPSIS
igawk [ all gawk options ] -f program-file [ -- ] file ... igawk [ all gawk options ] [ -- ] program-text file ... DESCRIPTION
Igawk is a simple shell script that adds the ability to have ``include files'' to gawk(1). AWK programs for igawk are the same as for gawk, except that, in addition, you may have lines like @include getopt.awk in your program to include the file getopt.awk from either the current directory or one of the other directories in the search path. OPTIONS
See gawk(1) for a full description of the AWK language and the options that gawk supports. EXAMPLES
cat << EOF > test.awk @include getopt.awk BEGIN { while (getopt(ARGC, ARGV, "am:q") != -1) ... } EOF igawk -f test.awk SEE ALSO
gawk(1) Effective AWK Programming, Edition 1.0, published by the Free Software Foundation, 1995. AUTHOR
Arnold Robbins (arnold@skeeve.com). Free Software Foundation Nov 3 1999 IGAWK(1)
All times are GMT -4. The time now is 08:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy