All Questions
79 questions
1
vote
1
answer
199
views
How to trace file descriptor duplication?
I am learning to use redirection. the typical operation is like below:
command > file 2>&1
Refer to APUE 3.10 and 3.12, I think the critical syscall sequence is like below:
open(...
1
vote
1
answer
110
views
Bash: How to read the script when sourcing it
When bash is executing a script, ls -la /proc/<pid of bash>/fd shows "255 -> /path/to/script".
I think that bash reads the script via file discriptor 255, and executes the commands ...
0
votes
1
answer
821
views
How can I loop over all directories and subdirectories and find files with a specific extension, then run FFMPEG on them, then copy them to a new lib
Ive been researching all of today and yesterday trying to find a solution, none have worked for me so far.
For example: https://stackoverflow.com/questions/5784661/how-do-you-convert-an-entire-...
0
votes
1
answer
312
views
Working with file descriptors in the (bash) shell?
I came across the following set of shell commands for reading and writing to serial ports, from this thread:
stty -speed 19200 < /dev/ttyS0 # sets the speed of the port
exec 99<>/dev/ttyS0 (...
1
vote
1
answer
122
views
Inserting a file without altering the folder's modification timestamp?
I have hundreds of folders with modification timestamps I'd like to preserve.
Now I need to copy a single file into them.
Aside from this way...
timestamp=$(stat -c %y /foldername)
cp /tmp/file.jpg /...
0
votes
1
answer
437
views
Loop multiple video files to compress them all in one directory?
I'm new to linux. I need some help. I want to compress all files present in a directory with same extension. The output should be with same name and extension. I want to run a shell loop to do this. ...
0
votes
2
answers
207
views
move recently created files matching a pattern from one folder to a different one
I am looking for a bash script example which does the following:
I have files being written under /tmp folder
I do at the xterm prompt, ls -ltr which gives me a list of recent files such as:
...
2
votes
1
answer
2k
views
How to bulk rename files/directories containing spaces?
How can you bulk rename many files and/or directories by replacing a
snippet f o o with b a r in the file/directory name?
For each suggested method, preferably answer the following questions.
Is it ...
-1
votes
5
answers
227
views
Reducing HDD seek time in reading the contents of many files in bash [closed]
I read millions of files in subdirectories of /XX/XX/XX/ to process the content of each file. In PHP, I read the files as
foreach(glob("/folder/*") as $a){
foreach(glob("$a/*") ...
1
vote
1
answer
94
views
Delete sub-directories based on matching information from column
I want to keep only those sub-directories that are present in the corresponding directory from CSV file.
The file structure looks something like this:
100_folder/
├── folder_11
├── folder_25
├── ...
4
votes
1
answer
4k
views
How to make `du` only include regular files in its output?
I want to list all files in descending order based on disk usage, and have obtained the following commands from this:
To list the top 10 largest files from the current directory: du . | sort -nr | ...
-1
votes
2
answers
2k
views
I moved a file and I want to know the previous directory for it
Suppose I have a file I moved to someplace but I don't know where it was when I moved it.
How can I know it the previous directory?
Suppose I have changed the directory a lot so cd - will not work.
...
1
vote
3
answers
242
views
I want to write a bash script to separate characters from special characters?
I am new to bash. I want to write a bash script where I have a file, "file.txt".
I want to cut & paste normal characters to charecters.txt & special characters to special.txt.
...
1
vote
1
answer
382
views
How to rename nested folders?
So I have a bunch of folders in the format of: .../course/year/... and I often reorganize them so that the format then changes to this: .../year/course/.... I've been meaning to learn how to write ...
1
vote
4
answers
587
views
How can I rename a file in a nested path "in place," i.e. without re-typing the full path? [duplicate]
I find myself frequently needing to rename different files with mv that are in deep directories:
mv /a/long/path/to/a/file.txt /a/long/path/to/a/file.txt.bak
But I don't want to retype the full path ...