could you please explain your code a little bit. its doing the right thing but i am kind of confused
This is how I did but it involved a lot of steps and few manual edits as well.
list the directory tree
find the specific directory
create the new directory where the files are supposed to be moved
awk '{print $0"/Fitted_Data/"}' petdir.txt >petfit.txt
extract the key words
sort files accordingly in excel and then move
i could have used sort -k 1,1 here
...could you please explain your code a little bit. its doing the right thing but i am kind of confused...
Well, it would've been much easier for me if you had asked *specific questions* about the code. It's very difficult for me to gauge your level of understanding of different concepts like -
(a) the options passed to the perl interpreter, e.g. "l", "n", "e"
(b) the chomp operator of Perl
(c) the concept of hashes in Perl, and in general
(d) level of understanding of regular expressions
(e) BEGIN and END blocks in a Perl one-liner
(f) the "uc" function of Perl
So, I will try to explain my code at a very high level. If you want to delve into specifics, you may want to look up all the concepts (a) through (f) in a good book on Perl, or at the perl.org website, or by talking to your local Perl guru.
In one sentence - I built a hash that had filenames from "img.txt" as the keys and their destination directories from "petdir.txt" as their corresponding values.
Here's the code spread out and documented -
Hope that clears up any questions that you might have.
Hi Guys,
I need to copy the files to respective directories based on name of the file. My script is something like below
con=$1
for file in `cat $con`
do
file_tmp=$(ls -t1 $path| grep -i $file | head -n 1)
echo $file_tmp
if
then
cp $path$file_tmp $DIR/ap
if
then... (16 Replies)
Hii,
Could someone help me to append string to the starting of all the filenames inside a directory but it should exclude .zip files and subdirectories.
Eg.
file1: test1.log
file2: test2.log
file3 test.zip
After running the script
file1: string_test1.log
file2: string_test2.log
file3:... (4 Replies)
Hi frnds,
My requirement is I have a zip file with name say eg: test_ABC_UH_ccde2a_awdeaea_20150422.zip
within that there are subdirectories on each directory we again have .zip files and in that we have files like mama20150422.gz and so on.
Iam in need of a bash script so that it unzips... (0 Replies)
#!/bin/bash
#
name=$1
type=$2
number=1
for file in ./**
do
if
then
filenumber=00$number
elif
then
filenumber=0$number
fi
tempname="$name""$filenumber"."$type"
if (4 Replies)
I have a number of files in directories labeled like this:
/Data/tr_gray/tr_DTI/dti_FA.nii.gz
(the brackets here represent a range of number that the files are labeled with)
I need to rename each dti_FA.nii.gz file according to the name of the folder it resides in. For example, the file ... (3 Replies)
Hi, since half an hour I currently try to write a script that will:
1) Extract every debian file in a directory
2) Extracts it to a folder that matches the debians filename
3) Extracts it so the structure looks like that:
DEBIANFILENAME
|
-------------- DEBIAN
... (9 Replies)
Hey guys,
I need to know how to locate all .htaccess files on the server and make a backup of them in the folder they reside before I run a script to modify all of them.
So basically taking dir1/.htaccess and copying it as dir1/.htaccess_bk
dir2/.htaccess copying as dir2/.htaccess_bk... (5 Replies)
I was wondering if someone could help me with this:
I have multiple directories and subdirectories with files in them. I need to move all files from all directories and subdirectories into one root directory. However, when i do
find /home/user -mindepth 1 -iname "*" -type f -exec mv {} . \;
... (3 Replies)
If I execute the command "ls -l /export/home/abcde/dev/proj/code/* | awk -F' ' '{print $9}' | cut -d'/' -f6-8" it will list all the files in /export/home/abcde/dev/proj/code/ directory as well as the files in subdirectories also
proj/code/test.sh
proj/code/test1.c
proj/code/unix... (8 Replies)
Hi all,
I'd very grateful for some help with the following.
I have a variable number of subdirectories each of which contain a uniquely names results file of the form Results*.dat.
I would like to search through all subdirectories and copy out these results file to another directory so that... (3 Replies)