Sort all files in one folder


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Sort all files in one folder
# 8  
Old 03-18-2018
What's inputfile's contents? Does that file exist?
# 9  
Old 03-18-2018
If you were using a standards-conforming shell (such as bash or ksh), you could use something like:
Code:
for inputfile in AC-*
do	sort -n -o z-"$inputfile" "$inputfile" && rm "$inputfile"
done

Since you choose to use csh, it is up to you to translate this code to create a loop in csh and to only run the rm command after if verifies that the sort command completed successfully.
# 10  
Old 04-01-2018
I don't have a file called inputfile. I tried to install bash to my pc but I didn't succeed, so I have no other option to use C Shell and Unix subsystems for Windows. Could somebody help me to make the codes that have been offered in this thread before suitable for C Shell?
# 11  
Old 04-01-2018
What output do you get when you run the command:
Code:
whereis sh bash csh ksh

in csh?
# 12  
Old 04-02-2018
Quote:
Originally Posted by Eve
I don't have a file called inputfile.
Perhaps not, but you do *have* some (file that serves as) inputfile, no? It makes sense to call a variable holding the name of it "inputfile". Corollary advice: when the navigation system in your car tells you to "turn right" it doesn't mean you should rotate clockwise on your seat either.

Quote:
Originally Posted by Eve
I tried to install bash to my pc but I didn't succeed, so I have no other option to use C Shell and Unix subsystems for Windows.
bash is part of the SUA, so it should be already there when you install it (correctly). I suggest you get the installation of the SUA right first and only then start to worry about C shell - if it is still necessary at all, that is. Doing something wrong first and then patch it somehow to almost work is a sure way to disaster in the long run anyway, so it is better to correct that now better than later.

I hope this heps.

bakunin
# 13  
Old 04-02-2018
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.

A reply to Don Cragun

If I will run

Code:
whereis sh bash csh ksh

I will get

Code:
whereis: Command not found.

# 14  
Old 04-02-2018
OK. What output do you get from the commands:
Code:
echo "PATH=$PATH"
ls /bin/*sh /usr/bin/*sh

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