Visit Our UNIX and Linux User Community


how to create folder wen the condition satisfied


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to create folder wen the condition satisfied
# 1  
Old 10-08-2007
how to create folder wen the condition satisfied

hi

i hav files ha1j ha2m ha3n ha4q ha5s ...like tat im having some 20 files ..and i want to create a folder as the same amount of files which im having wen the condition if loop is satisfied ..

thank you
# 2  
Old 10-09-2007
what is the if condition and the folders name?
# 3  
Old 10-09-2007
can you explain your question in more details ?????
# 4  
Old 10-09-2007
hi

my program is to sort the files and my files will be like tis

engPG1j1.top
engPG2h3.top
engPG3g5.top
engPG4r6.top
engPG5y1.top
engPG1u3.top
engPG2w8.top
engPG3e5.top
engPG4m3.top
etc...

And i have to create N folders at run time as many PG1 Files
say suppose im having 5 PG1 files ,then i have to create 5 folders and
each PG1 files should go into each folder again each PG2 files have to do the same
finally it will be (PG1,PG2,PG3,PG4,PG5)in one folder like tat i have to do

Thank you
# 5  
Old 10-09-2007
i am assuming u hv some files like 20 after 20 files reading u want to create a folder ryt.

#!bin/ksh
count=` find $HOME /- maxdepth 1 - name "test_dat*.txt" - print | wc -l
if [ $count -gt 0 ]

then
for $txtfl in $HOME/test_dat*.txt;
do
echo "copy ur files in $txtfl"

cat $txtfl >> $HOME/dnew/dfile.dat
done;
print "moved sucessfully"
fi

i hope this will work ..
creates a new folder and file
# 6  
Old 10-09-2007
thank you for ur great idea
its working man thank u a lot Smilie

Previous Thread | Next Thread
Test Your Knowledge in Computers #409
Difficulty: Medium
XENIX is a discontinued version of the UNIX operating system for various microcomputer platforms, licensed by Microsoft from AT&T Corporation in the late 1970s.
True or False?

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

How to create folder by using if and elif condition?

Hi All, I have already code to create folder for one country let say US , now we want to create folder/directory for JP country also using shell script , application server. $COUNTRY='US' if ] then if mkdir -m 777 -p /opt/TEST/$COUNTRY/$INVOICE >/dev/null 2>&1 | tee -a ... (5 Replies)
Discussion started by: Boost
5 Replies

2. Shell Programming and Scripting

Create Dynamic if condition

Create Dynamic If condition Hi, I have a file color.txt which has data as shown below Red Blue Green Yellow White Pink Black Based on a variable I execute a tail command as shown below tail -${LEFT_OVR} color.txt LEFT_OVR can be any number less than count of number of lines in a... (7 Replies)
Discussion started by: wahi80
7 Replies

3. Shell Programming and Scripting

If both condition satisfied

pattern tin loop 3 tin xarg 1 tin jim 5 tin icon 2 tin tour 4 patn.out tin loop 3 tin jim 5 tin icon 1 tin tour 2 while read one two three do awk '$2 ~ /'"$two"'/' patn.out || while read four five six do awk -v n1=$three -v n2=$six '{BEGIN (n2<n1)?1:0}' done<patn.out... (3 Replies)
Discussion started by: Roozo
3 Replies

4. UNIX for Dummies Questions & Answers

Create a condition for a non-included string

hey, just want to ask how to check this scenario a="apple banana cherry" if egg=0 fi how do you do the condition? thanks! (2 Replies)
Discussion started by: h0ujun
2 Replies

5. Shell Programming and Scripting

create separate file after checking condition..

Problem : I want to create a separate file for country list if condition is true. Please help. ***************************************************** Input file: SV-INCR-139302-365540488-201104090934.sqllog SV-INCR-1082-552793184-201104040805.sqllog SV-INCR-1077-855045741-201104040805.sqllog... (4 Replies)
Discussion started by: humaemo
4 Replies

6. Shell Programming and Scripting

how to create folder and sub-folder in UNIX ?

Hi all, I have the following code to check the whether the folder is exist in my system. if ; then echo 'folder exist'; else echo 'folder not exist'; mkdir /home/batch/testing ; fi When I remove the "testing" folder from "/home/batch" directory, the code is working fine. But when I... (2 Replies)
Discussion started by: suigion
2 Replies

7. UNIX for Dummies Questions & Answers

until loop : running even if condition is satisfied

I am checking one until loop with the following logic until || |||| do sleep 30 done before running this i am exporting above variables to SUCCESS.But the loop is running in infinite loop.My requirement is to make the loop run until all the 3 variables are SUCCESS or any of the 3... (2 Replies)
Discussion started by: dr46014
2 Replies

8. UNIX for Dummies Questions & Answers

Changing old file name to new one if the old file name satisfied certain condition

Hi guys, I desperately need your help on my problem:- I got a folder in my directory that has many files in it. Most of the file's name is starting with certain prefix. Eg: ABC, CDE, EFG, etc. I only want to change file name that is starting from certain prefix and the rest I want them to... (1 Reply)
Discussion started by: balzzz
1 Replies

9. Shell Programming and Scripting

print remaining file after a condition is satisfied

Hi , could any one suggest me that how to determine if the first field is numeric and if it is greater than another number then from that point everything else should be printed using awk. I have tried this : awk -v xxxx=$xxxxx ' BEGIN { enable=0 } { print $1 if ( ( $1 !~ "^*$" ... (5 Replies)
Discussion started by: hitmansilentass
5 Replies

Featured Tech Videos