Sort all files in one folder


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Sort all files in one folder
# 15  
Old 04-02-2018
Quote:
Originally Posted by Eve
I would like to make the question simpler - how to simply sort all of the files in one folder. Just like
Code:
sort  >

I have 6000 files in that folder and I would like to know if it is possible to sort all of them with one command.
.
.
.
This simpler question of yours has been answered in post#9, albeit in bourne shell "language". You even had an attempt of a solution to a similar problem in csh "speak" in post#4.
You insist on a full blown csh solution (for not being able to use that bourne one) for two weeks now - chances are dwindling you'll get one unless you translate / create it yourself.
# 16  
Old 04-03-2018
A reply to Don Cragun

Code:
echo "PATH=$PATH"   gives

PATH=/bin:/opt/gcc.3.3/bin:/usr/contrib/bin:/usr/X11R6/bin:/usr/local/bin:/usr/c
ontrib/win32/bin

ls /bin/*sh /usr/bin/*sh  gives

/bin/chsh       /bin/rsh        /usr/bin/chsh   /usr/bin/rsh
/bin/csh        /bin/sh         /usr/bin/csh    /usr/bin/sh
/bin/ksh        /bin/tcsh       /usr/bin/ksh    /usr/bin/tcsh

# 17  
Old 04-03-2018
Quote:
Originally Posted by Eve
Code:
ls /bin/*sh /usr/bin/*sh  gives

/bin/chsh       /bin/rsh        /usr/bin/chsh   /usr/bin/rsh
/bin/csh        /bin/sh         /usr/bin/csh    /usr/bin/sh
/bin/ksh        /bin/tcsh       /usr/bin/ksh    /usr/bin/tcsh

I can't understand why you steadfastly insist on using the C-shell. From your output:

Code:
/bin/csh
/usr/bin/csh      # these two are C-shells

/bin/sh
/usr/bin/sh       # these two are Bourne-shells, the ancestor of both bash and ksh

/bin/ksh
/usr/bin/ksh      # these are Korn-shells, the preferable tool

/bin/tcsh         # these are Tenex-C-shells, a more modern and matured
/usr/bin/tcsh     # (but unfortunately non-standard) version of the C-shell

You could run most of the scripts suggested to you in ksh as well as in bash and even if you would insist on C-shell you should use tcsh instead of the original csh.

I hope this helps.

bakunin
These 2 Users Gave Thanks to bakunin For This Post:
# 18  
Old 04-03-2018
As bakunin has already implied, if you run the code I suggested in post #9 in this thread with ksh it should do exactly what you said you want to do. (You might note that in that post I said it would work with either bash or ksh.)

Depending on the vintage of sh on your system, that code might also work if you run it with sh or even rsh.
This User Gave Thanks to Don Cragun For This Post:
# 19  
Old 04-04-2018
Hi! Thank you for your help! I really didn't know that I have the necessary shells in my pc since I'm relatively unexperienced. Now that I've found them evetything works great! Solution offered in post #9 works great in ksh! Thank you Don Cragun! This thread can be marked solved!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Request for Shell script to move files from Subfolder to Parent folder and delete sub folder

Hi Team, I am new to shell script and there is a requirement where files should be moved from Subfolder to parent folder. Eg: parent folder --> /Interface/data/test/IN Sub folder -->/Interface/data/test/IN/Invoice20180607233338 Subfolder will be always with timestamp... (6 Replies)
Discussion started by: srivarun15
6 Replies

2. Shell Programming and Scripting

Shell scripting for moving folder specific files into target directory of that country folder.

I need help to write shell script to copy files from one server to another server. Source Directory UAE(inside i have another folder Misc with files inside UAE folder).I have to copy this to another server UAE folder( Files should be copied to UAE folder and Misc files should be copied in target... (3 Replies)
Discussion started by: naresh2389
3 Replies

3. Shell Programming and Scripting

Bash script to sort files into folder according to a string in the filename

Hi all. I am very new to linux scripting and i have a task i can only solve with a script. I need to sort files base on the date string in their filenames and create a folder using the same date string then move the files to their respective folders. Scenario: Folder Path:... (1 Reply)
Discussion started by: ace47
1 Replies

4. Shell Programming and Scripting

URGENT!!! bash script to sort files into folder according to a string in the filename

Hi all. I am very new to linux scripting and i have a task i can only solve with a script. I need to sort files base on the date string in their filenames and create a folder using the same date string then move the files to their respective folders. Scenario: Folder Path:... (1 Reply)
Discussion started by: ace47
1 Replies

5. Shell Programming and Scripting

Help with sort folder results

Here is the code, but the list is not sorted properly (alphabetically)? <?php function folderlist(){ $startdir = './'; $ignoredDirectory = '.'; $ignoredDirectory = '..'; if (is_dir($startdir)){ if ($dh = opendir($startdir)){ while (($folder = readdir($dh)) !== false){ if... (0 Replies)
Discussion started by: mrlayance
0 Replies

6. Shell Programming and Scripting

Find all text files in folder and then copy to a new folder

Hi all, *I use Uwin and Cygwin emulator. I´m trying to search for all text files in the current folder (C/Files) and its sub folders using find -depth -name "*.txt" The above command worked for me, but now I would like to copy all found text files to a new folder (C/Files/Text) with ... (4 Replies)
Discussion started by: cgkmal
4 Replies

7. Shell Programming and Scripting

check how many files in folder or total files in folder

Hi all, I have copied all my files to one folder.and i want to check how many files (count) in the folder recently moved or total files in my folder? please send me the query asap. (3 Replies)
Discussion started by: durgaprasad
3 Replies

8. Shell Programming and Scripting

script for Finding files in a folder and copying to another folder

Hi all, I have a folder '/samplefolder' in which i have some files like data0.txt, data1.txt and data2.txt. I have to search the folder for existence of the file data0.txt first and if found have to copy it to some other file; next i have to search the folder for existence of file... (5 Replies)
Discussion started by: satish2712
5 Replies

9. UNIX for Advanced & Expert Users

Auto copy for files from folder to folder upon instant writing

Hello all, I'm trying to accomplish that if a file gets written to folder /path/to/a/ it gets automatically copied into /path/to/b/ the moment its get written. I thought of writing a shell script and cron it that every X amount of minutes it copies these files over but this will not help me... (2 Replies)
Discussion started by: Bashar
2 Replies

10. Shell Programming and Scripting

how to sort the file in specified folder

hi im having soo many .top files and i have to sort a set of files in one folder like tat so many sets of folders have to be created ... like say i have the file name j1 , g2 ,s3,k4,h1,j2,k3,s4..And i have to create one folder in tat i to have copy the files j1, g2 ,s3,k4 in one folder and... (0 Replies)
Discussion started by: maximas
0 Replies
Login or Register to Ask a Question