Beginner need help how file moving script could look like


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Beginner need help how file moving script could look like
# 1  
Old 01-25-2019
Beginner need help how file moving script could look like

Hi there,
I am an absolut beginner in scripting.
I am using Ubuntu Linux 18.04 LTS:
I just need some hints/suggestions how a script could look like doing the following stuff:

assuming I am in directory "base_directory"
like
xyz@mypc:~/base_directory$

within the "base_directory there are some subfolders (random name) having subfolder (random name)
there is a structure like:

Code:
base_directory/t3egjtj/g353grrhg/ and
base_directory/t464rrgg/3t344gf/
base_directory/f3h4egg3g/3h44geg/
base_directory/hejg3g/fg4j5j/

and so on....

each of the "sub-subfolders" contains several files

like ffe.txt, dwfekt.c etc.

now would like to grap e.g. all files with .c extension of every sub-subfolder and
move all files with .c extension to e.g. folder

Code:
/my_destination_folder


is there an easy way to do so?

sorry for such a dump question but I am completely new in this and want to check
how much effort it takes to implement (maybe such simple) file operations.

Best Regards

dut


Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 01-25-2019 at 03:54 PM.. Reason: Added CODE tags.
# 2  
Old 01-25-2019
Welcome to the forum.


Are those subdirectories always two levels deep, or is that depth arbitrary? Are the .c files only in the leaf directories, or all over the place? Do ALL .c files go into one single target directoy? Do you know about the find command, which is ideally suited for task like this?

Last edited by RudiC; 01-25-2019 at 04:15 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script for moving one file with date content in name

Dear All, I am having a database that generates daily backup files in the below format. abc_date_0010.zip. Can you please suggest a method to copy the last day's file to another location. I am trying with if statement, but having difficulty while I use the condition like if ; then ... (4 Replies)
Discussion started by: skooby
4 Replies

2. UNIX for Dummies Questions & Answers

Beginner needs help with first script

Hi, so I have been doing ok making a relatively simple script just processing some data. However I am now at the point where im struggling to find the specific help I need. I have files in the form of yyyy.ddd.hh.mm.ss.stationnumber.component (they are earthquake events). eg.... (12 Replies)
Discussion started by: neneman3000
12 Replies

3. Homework & Coursework Questions

Shell Script (beginner)

1. The problem statement, all variables and given/known data: Arguments: http://farm9.staticflickr.com/8070/8212131370_8b6e8c10c5_c.jpg I am given these three arguments. $1, $2, $3 The first argument is the path to a directory. So, how would I go into the directory and compare files? I... (5 Replies)
Discussion started by: spider-man
5 Replies

4. UNIX for Dummies Questions & Answers

File Moving Script

I want to make a script that moves all files with a keyword on it to another folder. and lets me know how many files it moved with that keyword. Im a total newbie with scripting so a little help would be much appreciated. (3 Replies)
Discussion started by: marchina
3 Replies

5. Shell Programming and Scripting

Shell Script for moving 3 days old file to Archive Folder

Hi Experts, I have a "Source" folder which may contain some files. I need a shell script which should move all files which are older than 3 days to "Archive" folder. Thanks in Advance... (4 Replies)
Discussion started by: phani333
4 Replies

6. Shell Programming and Scripting

Need help with (beginner?) script

I am in an intro to unix/linux course, and need some help with a project. We are tasked with creating a basic script to automate a task that an Admin might need to do. We submitted ideas and mine was to have the system keep a record of log in and log out times for users. I thought this was going... (3 Replies)
Discussion started by: DethbyNo
3 Replies

7. Shell Programming and Scripting

moving file to directory in script

hi i am reading files from directory,if the files matches certain condition i need to move that file to another directory i am using if then mv $file1 > $UNIQDIR fi but i am gettin error , please help thanks Satya (4 Replies)
Discussion started by: Satyak
4 Replies

8. Shell Programming and Scripting

shell script for moving all the file from the same folder

Hi , I need a shell script which basicaly moves all the files from one folder say folder x to folder y and once they are moved to folder y a datetimestamp should be attached to there name for ex file a should be moved to y folder and renamed as a_20081015 (1 Reply)
Discussion started by: viv1
1 Replies

9. Shell Programming and Scripting

need shell script for moving file one by one

#SD=source dir TD= target dir SD="$/amddev/app01/manoj/new/scripts/old" TD="$/amddev/app01/manoj/new/scripts/new" EXT="$*.txt" for i in `ls -F "$SD"/*"$EXT"|grep -v /$` do mv "$SD" "$TD" if then echo "$i" successfully moved echo Manoj successfully..1 ( here i... (8 Replies)
Discussion started by: manojkarthi
8 Replies

10. Shell Programming and Scripting

Beginner needs help with script

I would like to get a sample script (ksh or bash, or both so I could see the differences) What I want to do with the script is send an daily email to myself that contains the following: The number of files in a directory The total size of the files in that directory The contents of a file... (2 Replies)
Discussion started by: martyb555
2 Replies
Login or Register to Ask a Question