Hello all.
I have 100 sub-directories that "rar" files exist in them, How can I move all rar files into parent directory?
I used "find sourcedir -type f -exec mv {} targetdir \; " but i just copy one file and all files deleted
Thank you.
Hello, I have an embedded linux device. I can connect to the device and I can upload or download files. No problem with this. But, at first connection, I want to connect to "/" directory instead of "/root". In the device file system, there are files ssh_config and sshd_config under /etc/ssh directory. I think I have to do something with these files but I don't know what.
I don't exactly know what mean "/root" and "/" directories. I think that the real root directory is "/" directory which is empty but when I connect with filezilla, the "/root" directory is the default so I had to go back to / directory everytime.
Hi Experts,
I am trying to make new enteries in a csv file in new column but am not able to do so.Please help for the same.
Requirement:
There are multiple directories & within those directories i have sub-directories and i want to build a csv file with 2 columns of Directories mapped to their sub-directories. Can you please help me with this. I tried the following code:
Code:
#!/bin/bash
homeDir="$HOME"
ls ~/Parent/ | cut -c1-9 > ~/test_111.csv
while read Child
do
Entry="$(ls $homeDir/Parent/$Child/ABC/XYZ/DEF/PQR)"
echo $Entry
for (( c=1; c<=5; c++ ))
do
sed -i ci"$Entry" test_222.csv
done
done < test_111.csv
Basically i want two columns of csv file , First column should have Child name & Second cloumn should have Sub-Directory name inside PQR Directory.
Any help will be useful on this.
Thanks in Advance!
Best Regards,
Vijay Bhatia
hello all,
please help me with python ftplib. i was trying to copy files from my linux machine to a windows server using ftplib. everything was working good. but i'm only able to copy files from the same directory the script is. how do i copy files from a different directory? i always get "file not found error message". here's my code :
Code:
tester_name = str (socket.gethostname())
def upload(ftp, file):
ext = os.path.splitext(file)[1]
if ext in (".txt", ".htm", ".html"):
ftp.storlines("STOR " + file, open(file))
else:
ftp.storbinary("STOR " + file, open(file, "rb"), 1024)
parse_source_path = ('/path/to/where/i/go/')
parse_source_file_list = os.listdir(parse_source_path)
ftp = ftplib.FTP("server_IP")
ftp.login("username", "pass")
folder_list = []
ftp.dir(folder_list.append)
if str(tester_name) not in str(folder_list) :
ftp.mkd("%s"%tester_name)
ftp.cwd("%s"%tester_name)
for files in parse_source_file_list :
print files
upload(ftp, files)
else :
print "later"
Hello Folks.
I'm searching for a easy way to rename multiple files from CLI but didn't find any easy way for me so I'm reaching out to you guys for help.
This is what I want to do (from CLII or script). I want to move files with a sequence number on the name of the files (msg0000, msg0001, msg0002 and so on) to let's say msg0066, msg0067 and so on. Each of this file name has two other files (msg0000.wav, msg0000.WAV and msg0000.txt).
The idea is to move them from one directory to another and following a sequence in the file names, is there a way I can do this pain free?
Any help on this matter will be greatly appreciates and I'm talking about over 100 files I need to move following the sequence of the receiving directory.
Thanks!
I'm just getting into Bash scripting, and would appreciate some help with this question. My music collection is split into a smaller, "active" set, kept on my laptop, and a much larger collection on an external hard drive. I've just converted some of the larger filetypes on my "active" set to *.mp3, and now want to move all the original files (*.flac) to the external hard drive. I need some help putting together a command or script that will recursively search my active music set for *.flac and then move them, but keeping the source directory structure. Some or all of these subdirectories may not exist on the destination.
eg. On the active music set, I may have:
/Music/artist1/album1/(a mix of *.mp3 and *.flac files)
/Music/artist2/album1/(a mix of *.mp3 and *.flac files)
and on the hard drive
/Music 2/artist1/album2/(the contents of the album)
So when copying, it'll need to create "/album1/" in "artist1" on the destination, and also "/artist2/album1/"
Thanks in advance!
Hello every one,
I need to copy many files in to many folders in once, for example I have files result_1 result_2 result_3 and want to copy them to directories 1 2 3 respectively, how can I do that, I have tried cp, echo and find syntax but did not work out.
Any idea?
I am new to Bash scripting.
I have a main directory called Photos which has many subdirectories like People, Places and Things. Each of these subdirectories is populated by other subdirectories and lots of JPG photo images.
The digital cameras name the files in a way that is difficult to manage with web hosting.
I would like to go to each directory and subdirectory and rename the photos 1.jpg, 2.jpg, 3.jpg, etc. so that I can use a simple XML template to access them by specifying only a hosting directory.
I tried to use the following script:
#! /bin/bash
cd /home/paul/test
find . -name "*.jpg" -print0 | rename -v 's/.+/our $i; sprintf("%d.jpg", 1+$i++)/e' * -vn
exit 0
It successfully renames all of the files in all of the directories, but it does not restart the numbering for each new subdirectory. So first it goes through Photos and renames the three JPG files there 1.jpg, 2.jpg and 3. jpg, and then it opens the first subdirectory People and names the three JPG files there 4.jpg, 5.jpg and 6.jpg. Next it moves to the next subdirectory and continues sequential renaming until it is done.
I want it to restart sequential renaming with each new subdirectory, so that after renaming the three JPG files in Photos to 1.jpg, 2.jpg and 3.jpg, it moves to the first subdirectory and renames the JPG files there starting with 1.jpg again.
That way I use the links 1.jpg, 2.jpg, 3.jpg, etc in the XML template and just change the directory name to download the photos from the web.
Thanks for any help you can give me.
I copied the following from my linux console.
grep -lr "SMTP" *.ini
grep: *.ini: No such file or directory
I wanted to search recursively under current location in files with extenstion .ini
Actually there are files that contain "SMTP" under this directory. But I got the above error message.
What is wrong? I am using centos 6.
Thanks,
3rock
Hi all,
I'm trying to identify files that do not have matches for certain strings. FYI, these are files of DNA sequences and I'm trying to find those that are NOT sampled for any species by my group of interest (e.g., genes that are specific to that group of organisms).
I tried this code but it's actually yielding a list of files that DO match for my regexp.
Code:
for FILENAME in *.fas
do
grep -q -L ">PBAH" $FILENAME && grep -q -L ">SKOW" $FILENAME && grep -q -L ">CGRA" $FILENAME && echo $FILENAME
done
Basically I want to somehow go through and file files that do not contain ">PBAH" ">SKOW" or ">CGRA". Any assistance would be greatly appreciated!
Best,
Kevin
Directory /media/data/torrents/ has permissions 775, user yzt, group transmission
yzt and debian-transmission are members of the group transmission.
transmission-daemon is run by debian-transmission, and the new files it downloads have permissions 644, owner debian-transmission, group transmission. This is a problem, because I can't later move the files as my user, yzt, and need to be switching to root to change the permissions/ownership to be able to do so.
Using sticky bit I could copy it to anywhere else, but I'm interested on actually moving the file, not just copying it. I could run transmission-daemon as yzt and problem solved, but I rather have that internet facing service running by a limited user, just in case some vulnerability is found on Transmission.
So my question is, how can I set that every new file created under /media/data/torrents/ has permissions 775 like its parent directory?