Is it possible to trace which files are creating files in the /tmp folder on a linux OS? I want to back trace some files to find out where they have come from
If the files are open you could find the processes with something like
ll -d /proc/[1-9]*/fd/* | grep /tmp/
Related
I have a bunch of directories which were organized on date.
e.g.
the following directory are sequential dates.
/200001 ..../200201 /200202 /200203...../202209
There are tons of files in those directories and i'd like to move those files with name "*.csv" and the directory is from 200501 to 202209 to /tmp directory.
I know the following command is wrong, but it shows what i'd like to do
mv /{200501..202209}/*.csv /tmp
How can I do it by writing a shell script?
Sorry i am very new to os linux.
I've learned linux and there's my homework:
Show all files and directories in /usr and save the result in file usr.txt:
Show all files in /usr/bin and stop when the screen is full:
Hint: use command pipe and more
Find all files in /etc that the file name contains the word “log”:
Hint: use command grep
1.I searched copy command on google but there's just some commands about copy file not contents and I also use Y1G command but there're nothing happen.
2.I absolutely don't have any idea about how to pharse "the screen is full" by commands
3.I've use command find path -log /etc but there're no right result
Show all files and directories in /usr and save the result in file usr.txt:
cd /usr && ls -l > usr.txt
Show all files in /usr/bin and stop when the screen is full:
Hint: use command pipe and more
ls -l /usr/bin | more
Find all files in /etc that the file name contains the word “log”:
grep -ir "log*" /etc
I'm trying to download multiple files trough SFTP on a linux server using
sftp -o IdentityFile=key <user>#<server><<END
get -r folder
exit
END
which will download all contents on a folder. It appears that find and grep are invalid commands, so are for loops.
I need to download files having a name containing a string e.g.
test_0.txt
test_1.txt
but no file.txt
Do you really need the -r switch? Are there really any subdirectories in the folder? You do not mention that.
If there are no subdirectories, you can use a simple get with a file mask:
cd folder
get *test*
Are you required to use sftp? A tool like rsync that operates over ssh has flexible include/exclude options. For example:
rsync -a <user>#<server>:folder/ folder/ \
--include='test_*.txt' --exclude='*.txt'
This requires rsync to be installed on the remote system, but that's very common these days. If rsync isn't available, you could do something similar using tar:
ssh <user>#<server> tar -cf- folder/ | tar -xvf- --wildcards '*/test_*.txt'
This tars up all the files remotely, but then only extracts files matching your target pattern on the receiving side.
I currently have a number of drives mounted under "/media/" I want to recursively scan all the drives mounted looking for files with a specific extension "*.foo". Once found I want to symlink these files into a directory elsewhere. One requirement is that I keep the basename of the file the same when creating the symlink. I wasn’t able to come up with a an easy solution using "find -exec" on my own. Is there an easy way to do this?
find /media/ -name *.foo | xargs ln -s -t DIRECTORYYOUWANTLINKSIN
I'm struggling to only retrieve subfolders from a remote windows share with the following directory structure using smbclient. Is there a way of issuing a command to only get folders? The command I have so far is:
smbclient //$host/$share -U"$USER%$PASSWORD" -c 'cd RootFolder; prompt; recurse; mget Test*\'
RootFolder/
Test001/
Revisions.txt
Test002/
Revisions.txt
Test003/
Revisions.txt
Test001=2012_12_05.log
Test001=2012_12_06.log
Test001=2012_12_07.log
Test001=2012_12_08.log
... more log files here
You could pipe the output of your command through grep, looking for lines that end with /.
smbclient ... | egrep '/$'
Instead, you could mount the remote windows file system and then use the find command to search for folders. The find command will search recursively for all directories only. This would be my recommended approach. Assuming you mount the windows filesystem as /mnt/win_host...
find /mnt/win_host -type d