to check whether a directory or filename path is valid or not


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting to check whether a directory or filename path is valid or not
# 1  
Old 01-03-2009
to check whether a directory or filename path is valid or not

the script on excution should take a directory path from useran a numric input and it should check indicate whether its write or not?
if the cmmd sh<script-name>,dir/path.<500>" is greater than 500 in size should be copied to dir ,temp in pwd and display the mesage'files of 2000 bytes hav been copied to dir temp'
# 2  
Old 01-03-2009
Quote:
Originally Posted by arukr
the script on excution should take a directory path from useran a numric input and it should check indicate whether its write or not?

Do you mean "whether you can write to it" or "whether it's right"?
Quote:
if the cmmd

What's "cmmd"? If you mean "command", please say so. The posts in this forum should be in plain English.
Quote:
sh<script-name>,dir/path.<500>" is greater than 500 in size should be copied to dir ,temp in pwd and display the mesage'files of 2000 bytes hav been copied to dir temp'

That sentence makes no sense. Please rephrase it. Where you have code, please put it in [code] tags.
# 3  
Old 01-04-2009
I'm retyping the question as suggested

Script on execution should take a directory path from user and a numeric input.it should flag in case of input missing or wrong path .All files inside directory greater than a the numeric input specified should be copied to another directory temp .At last the total copied file size in temp should be displayed .
# 4  
Old 01-04-2009
Quote:
Originally Posted by arukr
Script on execution should take a directory path from user and a numeric input.

Where does it get the numeric input? From the user? From the standard input? From a file?
Quote:
it should flag in case of input missing or wrong path .

How do you determine whether the path is right or wrong?

What do you mean by "flag"? Should the script exit or should it continue? Should it notify the user?
Quote:
All files inside directory greater than a the numeric input specified

How do you determine whether a file is "greater than the numeric input"? Are the file names all numeric? Or do you want to test the contents of the files?
Quote:
should be copied to another directory temp .At last the total copied file size in temp should be displayed .
# 5  
Old 01-05-2009
is this one?

find $1 -size +$2c ! -type d | xargs ls -l |awk '{print $5}'

find $1 -size +$2c ! -type d | xargs -t -I{} cp {} /temp

the above shell can list the size in bytes of all the eligible files in the specified directory. and then write a loop to count the total size.
The second command can be used to copy the files to /temp directory.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Check for valid hostnames

Hello, I am trying to develop a script to check for valid hostnames. Below are the prerequisites for a valid hostname which I got from wiki : Hostnames are composed of series of labels concatenated with dots, as are all domain names. For example, "en.wikipedia.org" is a hostname. Each label... (8 Replies)
Discussion started by: rahul2662
8 Replies

2. Shell Programming and Scripting

Check if time format is valid

How can I validate if time (HH:MM:SS) argument is valid? I got this from web but I can't modify it to exit the script if the time argument is invalid. echo $1 | awk -F ':' '{ print ($1 <= 23 && $2 <= 59 && $3 <= 59) ? "good" : "bad" }' ex: ./script.ksh 12:34:21 = okay ./script.ksh... (10 Replies)
Discussion started by: erin00
10 Replies

3. Shell Programming and Scripting

Check if a string is a valid timestamp in UNIX.

Hi all, I have date and time value in a string, I want to check if it is a valid date and time. Need help on this. Thanks (7 Replies)
Discussion started by: Pratiksha Mehra
7 Replies

4. Windows & DOS: Issues & Discussions

Check dir for overly path+filename and list in txt

Well since Windows always laments over some of my files having a too long "path+filename" and it gets in the way of copying complete directory structures I would love to have a DOS Script that helps me with finding those. I already tried DCSoft Long Filename Finder but that is neither DOS based... (3 Replies)
Discussion started by: pasc
3 Replies

5. UNIX for Dummies Questions & Answers

How to check if file contains valid strings?

Hi All, I am a newbie...I would like to have a function which ll check if a file contains valid strings before "=" operator. Just to give you my requirement: assume my file has content: hello= gsdgsd sfdsg sgdsg sgdgdg world= gggg hhhh iiiii xxxx= pppp ppppp pppp my... (5 Replies)
Discussion started by: rtagarra
5 Replies

6. Shell Programming and Scripting

How to check if a filename in a directory starts with a certain string

Hello, Trying to iterate over set of file in current directory and check if the file name in that folder matches certain string. This is what I have so far. Here I am checking if the file name starts with nexus, if so echo file name to log file. Getting weird syntax errors. Any help is... (7 Replies)
Discussion started by: scorpioraghu
7 Replies

7. Shell Programming and Scripting

how to check for valid password

I need to check if an account has a valid password. Would something like this work? read ACCNAME if grep -q "^$ACCNAME:\$6:" /etc/shadow; thenI noticed every entry in my shadow file that has a password starts with $6 ... it works for my current setup, but would it always work? I can't test... (4 Replies)
Discussion started by: ADay2Long
4 Replies

8. Homework & Coursework Questions

Bash shell - Check if value is valid directory.

1. The problem statement, all variables and given/known data: The script usage will be as follows: library.third source_directory - Your script will display an appropriate error message and exit with status 3 if no parameters are given - Your script will display an appropriate error... (2 Replies)
Discussion started by: netmaster
2 Replies

9. Shell Programming and Scripting

Please help I want script to check filename, size and date in specify path.

Please help, I want script to check filename, size and date in specify path. I want output as: DATE: YYYYMMDD HH:MM ------------------------------------------------ fileA,filesize,yyyy mm dd HH:MM fileA,filesize,yyyy mm dd HH:MM fileA,filesize,yyyy mm dd HH:MM fileA,filesize,yyyy mm dd... (1 Reply)
Discussion started by: akeji
1 Replies

10. Shell Programming and Scripting

How to check for a valid numeric input

Hi Folks, I'm using bash script. I would like to check whether input is a number or not.(Only positive numbers).. if space or non numeric is entered, it should say "invalid input". pls help.. thanks in adv. Br/// Vijay. (1 Reply)
Discussion started by: Vijayakumarpc
1 Replies
Login or Register to Ask a Question