General :: Comparing A File Size To A Given Number?

Jul 26, 2011

I'm trying to write a script that takes two arguments, the first argument is a number, and the second argument is a filename. The shell script should indicate if the file's size is BIGGER or SMALLER the number provided. this is what i have sofar, am i on the write track, i'm hoping its just a problem with my if command

if [ $1 -h $2 ]
then
echo "$1 is bigger than $2"
else

[code]....

View 2 Replies


ADVERTISEMENT

General :: Comparing Two Files - Display The User Names That Are In The First File And Not The Second

Sep 17, 2009

Im trying to compare two files and I only want to display the user names that are in the first file and not the second.

So I have one file named final.txt (which contains every user name and only the user names in a list no other information)

Then I have another file Over1.txt (which only contains certain users that have different permissions This file is also setup differently with the user name and some information about the user after the user name.

I need a way to compare final.txt to over1.txt so that I will only display the names that are in final.txt but not Over1.txt

Ive tried using diff and comm but just cant seem to get it two work correctly. Im not sure if im missing a option or what.

View 5 Replies View Related

Programming :: Bash File Comparing - Report How Many Matching Words My Main File ?

Jun 9, 2009

I have been messing with diff and grep for 2 days now without result

I am trying to match a file consisting of words to many separate other wordfiles in a specific directory. one by one.

What i want the script to do is to report how many matching words my main file has with every file in the directory, each in turn

setup:

Each of em are plain text files with 1 word per line

Output should be something like:

SCRIPT REPORT:

View 8 Replies View Related

General :: List Folder Size And Number Of Files And Folders In Folder?

Nov 23, 2010

In Linux bash shell, for a given directory, how can I list:The create date for that directory The number of files in that directory The number of subdirectories in that directory.

View 3 Replies View Related

General :: Sort By Line Size (number Of Characters In A Line)?

Jan 8, 2010

I want to sort a number of lines based on their size:

data:
-------
12345678
87654321
1234

[code]....

Should output as:
-----------------
1
2
12
21

[code]....

But i'm gettings this with sort
----------------
1
12
123
1234

[code]....

Can we sort the above "data" text, based on "number of characters" instead of "character order"?

View 8 Replies View Related

General :: Script To Insert Number Of Lines In A File To The Start Of The File?

Sep 17, 2009

I'm looking for a way to insert the number of lines in a file to the start of the aformentioned file. This should be simple but as I am not used to scripts in Linux, I am finding it tough going. I can find the number of lines in a file easily enough via

filesize=$(awk 'END {print NR}' $1)

but as for inserting this into the first line, i'm failing to do so. I've tried some of the other approaches on these forums but none so far have been able to do so.

I've tried:

sed '1i$filesize' $1

but sed i requires a string, not a variable so no go I've also tried:

mv "$1" "${1}.bak" 2>/dev/null || touch "${1}.bak"
cat $filesize "${1}.bak" >"$1"

but again with no luck as cat seems to need an input stream Just to recap, i want to insert a line at the start of a given file that holds the number of lines the original file has.

ie the file:

a
b
c
d
e

should become:

5
a
b
c

[code].....

View 3 Replies View Related

Ubuntu :: Cli Comparing File Names Recursively?

Apr 24, 2011

I would like to use the command line to compare two directories against each other. I have two folders called music collection that have evolved over the last year on two separate computers. 90% of the two folders are the same, but there are small differences. I would like a solution that will print out all the differences so I can analyze them and choose what I want to do with them, before merging the two folders. for example.I would like some kind of output that shows the differences and where its located.

comparing MusicCollection1 and MusicCollection2
dif1.mp3 located in MC1/folder1 (this one I might want to keep and merge over)
dif2.mp3 located in MC2/folder3 (while this one I might realize does not exist in both folders because I deleted it for a reason)

I've looked at sort, uniq, and even tried scripting my own solution, but haven't come up with an elegant solution thus far. Its important that it is recursive because there are about 15 folders in Music collection and more folders under those 15.

View 3 Replies View Related

Server :: Comparing Zone File Counting And Same Name

Mar 29, 2011

I want to compare zone file counting and same name, not records etc of master and slave dns server so that i sure both server contains same copy of the files at a time. Any utility to compare such files in linux?

View 5 Replies View Related

Programming :: Comparing And Formatting The Text File

Oct 11, 2010

I need a script which can format the below text file which contains comments

Code:

Code:

Output should be:

Code:

Code:

Script should compare the column name and paste the output in above said manner.

View 13 Replies View Related

Ubuntu :: Split Big File Size Into Small File Size

Jun 10, 2010

Are there software that can split big file size into small file size in Linux?

View 1 Replies View Related

General :: Max Number From The Name Of A File?

Mar 24, 2010

I need to get the max number from the name of a file

Formant of the file name:
[a-zA-Z]*_[0-9][0-9]_[A-Z][A-Z].log
Delimiter as underscore '_'

[code]....

known part in the above file name will be GA.log A give directory may or may not contain files in the above format or may contain file other then the above format if so then ignore it.

Eg:-

1) Directory=/tmp/log having below listed files

ant_01_EG.log ant_02_GA.log ant_04_EG.log cvs_01_EG.log cvs_02_GA.log cvs_04_EG.log master_01_GA.log master_03_EG.log master_04_GA.log

[code]....

output=> 06

2) Directory=/tmp/log no files

cmd=> ls *[0-9][0-9]_GA.log 2> /dev/null | awk -F_ '{ print $2}' | sort -nr | head -n1 | awk 'BEGIN { if ($1 >0 ) x=0; else x=1 } END {printf "%02.0f
", $1+1}'

output=> 01

if there are no files the output should be 01 and if file(s) found the output should be next highest number+1, In the above example it is 06 My cmd is bit lenghty. reduce my cmd and it should be in one line.

View 6 Replies View Related

Ubuntu :: Bin Ash Shell - Creates A File With Name Of The Value $available_blocks Instead Of Using The '>' Sign For Comparing The 2 Numbers

Feb 23, 2011

Im using an if statement in the bin ash shell and it isnt working.

Code: if (( 5000 > $available_blocks )) then echo "WARNING Disk space low, "$pct_used" is used" fi

I don't think its a problem with the if. When i use that code it creates a file with name of the value $available_blocks instead of using the '>' sign for comparing the 2 numbers.

View 6 Replies View Related

General :: Limit On File Size - Doesn't Allow User To Create File Which Are Greater Than 100Kb

Jun 13, 2011

I was just testing specifying limit on file size to a user and have added the following to /etc/security/limits.conf bob soft fsize 100 This basically should have said not to allow bob to create anyfile greater than 100Kb in size.

But the interesting thing is, if bob already has any file which is greater than 100Kb in size, it even doesn't allow to log him into the system both from console and SSH. Also nothing is logged in logs.. How do I configure it so that, bob can login to the system even though he has any file greater than 100Kb (but doesn't allow him to create file which are greater than 100Kb) ??

View 3 Replies View Related

General :: Searching For Number Within A File?

Nov 9, 2010

I'm currently trying to design a small, simple enough shell program for area codes. I have a list of area codes in a database, and I am trying to write a program that will have a user input an area code, and then have the program print out information that immediately follows that area code in my database. I assume I need to use a find or locate command, but I'm not sure if I should be searching for a string or the number itself. The number could possibly occur at some other point in the file, though the way I have the file set up it only occurs once at the newline.

what function I should use and how I should go about it? As is I only have the absolute bare-bones beginning of having an echo for the prompt to input an area-code, and the read once it's input. Without the find I'm not sure how much farther I can get. Also, would it make it easier if I added some character such as a ! to the end of the number at the newline to make it easier to search for? With a macro that would be easy enough to do.

View 1 Replies View Related

Networking :: See The Number Of Packets Dropped By Kernel Due To Insufficient Queue Size?

Sep 15, 2010

As is known, there is a queue lies between the kernel subsystem and the network driver for incoming data. And if data come when this queue has no space for it, the data got dropped by kernel. Is there some way to see how many packets are dropped due to this buff penury? I tried netstat -s but could not find something useful. On the other hand, I found this 12176 packets collapsed in receive queue due to low socket buffer from netstat -s. I think this is something related to the per-socket buffer, but not the incoming queue between the network driver and kernel. Is this right?

View 1 Replies View Related

General :: Find Inode Of A Particular File Using Its Number?

Nov 16, 2010

Can we find the inode of a particular file using its inode number?

The reason is i want to know how many blocks are occupied by specific file.

if we consider block size of 1K.
if the file size is of 100 bytes. In such a case, when the file is
stored on disk, the file will occupy 100 bytes or 1K (since we have
choosen block size to be 1K) ?

View 6 Replies View Related

General :: How To Grep Negative Number In File?

Mar 4, 2010

I wanted to grep the line in a file starts with -1.000000e+00.

Tried grep "-1.000000e+00" *, got error "grep: invalid option --".
Neither of the following works:
grep "-1.000000e00" *
grep "1.000000e00" *

How do I grep a negative number with scientific notation?

View 3 Replies View Related

General :: Isolate A Number From A Text File Using Sed?

Mar 27, 2010

I'm trying to isolate a number from a text file using sed. The text file looks like this:

-GARBAGE-GARBAGE-GARBAGE- Number of frames: 183933 frames Codec -GARBAGE-GARBAGE-GARBAGE-

I tried the following:

Code:
sed "s/^.*Number of frames: //g; s/ frames Codec.*$//g" "info.txt" > "frames.txt"
Strangely, it only seems to be stripping off the end, but not the beginning, like so:
-GARBAGE-GARBAGE-GARBAGE- Number of frames: 183933

I'm obviously not using the command correctly, so what am I doing wrong?

View 8 Replies View Related

General :: Show The Number Of File On Folder?

Oct 21, 2010

My folder have some files and I want to show the number of files on folder at "Total file on folder: " Ex: Monday folder have six files and it will show "Total file on folder : 6" when I run a script. This is my code :

#!/bin/sh
if [ -d /home/kenzo/Monday/ ] && {
echo "Monday"
ls -l /home/kenzo/Monday/

[code].....

View 2 Replies View Related

General :: Print The Number Of Characters In The File?

Apr 6, 2010

# echo "foobar" > /tmp/word
# cat /tmp/word | wc -m
7

I want to print the number of characters in the file. Why does it output 7? Am I missing something obvious?

manpage:
-m, --chars
print the character counts

View 3 Replies View Related

Fedora :: Re-size Logical Volume And Then Re-size File System?

Jan 19, 2011

is lvresize with --resizefs options re-size the Logical Volume and then re-size the file system? i mean we don't need to use resize2fs?I looked at man pages but it doesn't explain this option.

View 3 Replies View Related

Red Hat / Fedora :: Inode Table Size And File System Size

Dec 14, 2010

How can we find the maximum size of the inode table and what decides it, and how the maximum size of volume of file system is decided ?

View 4 Replies View Related

General :: Can Get Version Number Of Tar Used To Create Specific Tar File?

May 19, 2010

I need to know the version number of tar used to create a specific tar file. How can I do that?

View 1 Replies View Related

General :: Remove A File On System Using Inode Number?

May 19, 2010

If you create a file on UNIX/linux with special chars, like touch "la*, you can't remove it with rm "la*. You have to use the inode number(you can if you add the before the name, I know, but you'd have to guess as a user that it was used in the file creation).

I checked the manpage for rm, but there's no metion of the inode number. Doing rm inodenumber doesn't work either.

What is the command for this?

View 4 Replies View Related

General :: Using Sed To Replace A *large* Number Of Variables In A File?

Jul 28, 2011

I have a large number of log files, on a linux box, I need to cleanse sensitive data from before sending to a third party. I have used the below script on previous occasions to perform this task, and it has worked brilliantly (script was built with some help from here :-)

#!/bin/bash
help_text () {
cat <<EOF
Usage: $0 [log_directory] [client_name(s)]
EOF

[Code]...

However, now one of our departments has sent me a CLIENT_FILE.txt with 425000+ variables! I think I may have hit some internal limit. I have tried splitting the client file into 4 with around 100000 variables in each, this still doesn't work. I'm loathe to keep splitting though as I have 20 directories with up to 190 files in each directory to run through. The more client files I make, the more passes I have to do.

View 2 Replies View Related

General :: Hard Drive - Get Block Number / Position Of File On HDD?

Feb 28, 2010

How can I retrieve the block number(s) of a certain file in a file system (the blocks the file is using on the harddisc)?

I'm using the gentoo linux based SystemRescueCD, so I got plenty of tools installed which might get that information for me.

View 1 Replies View Related

General :: Perl Script To Replace The Number From Text File?

Jun 21, 2010

on creating a new perl script which replace IP address from the text file. eg. If in a file, we found any word like 11.222.333.44 then it has to be replaced to XX.XXX.333.44

View 8 Replies View Related

General :: Determine Number Of Rows And Columns Of File In Shell?

Mar 4, 2010

if there's a tab-delimited file under /usr/desktop, how can I determine the number of rows and columns of the file in shell?And, if told the the 3rd column of the file contains only numerical values and all values in the 5th column are unique, how can I verify these in shell?

View 13 Replies View Related

General :: Create A File In The Current Directory Named '5' With The Number '2'?

Aug 24, 2010

Code:
$ echo 2 * 3 > 5 is a valid inequality. This will create a file in the current directory named '5' with the number '2' in it, the names of all the files in the current directory, followed by the number '3' and 'is a valid inequality.'

What I do not understand is why 'is a valid inequality' gets written to this file. I thought it would write '2', all the file names in the current directory, then '3' into the file called '5'. Why does the 'is a valid inequality.' get written to the file also?

View 3 Replies View Related

General :: Change All Number 10 In A Text File To Word Form?

Mar 20, 2011

I need to change all number 10 in a text file to word form, or in short from 10->ten. the thing is number 10 including in dates such as 10/22/1997 or 03-10-2011 should not be changed. im having some trouble because the file contains numbers like "price range from 10-50k".

this is just a sample.

name: john smith
birthday: 10-11-1995
date hired: 05/10/2010
expected salary: 10-50k
typing speed: 10 wpm

[Code].....

Using sed command is it possible to change like this..

View 11 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved