Skip to main content

All Questions

Tagged with
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(...
Yao Li's user avatar
  • 21
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 ...
user356126's user avatar
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-...
Mister SirCode's user avatar
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 (...
First User's user avatar
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 /...
lmoly's user avatar
  • 427
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. ...
Adnan Aslam's user avatar
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: ...
Eric's user avatar
  • 3
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 ...
Henke's user avatar
  • 181
-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/*") ...
Googlebot's user avatar
  • 1,959
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 ├── ...
botloggy's user avatar
  • 137
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 | ...
Shuzheng's user avatar
  • 4,871
-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. ...
Raghad Alhamima's user avatar
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. ...
IndiGo's user avatar
  • 11
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 ...
Ace Ryder's user avatar
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 ...
ascendants's user avatar

15 30 50 per page
1
2 3 4 5 6