All Questions
542 questions
0
votes
0
answers
67
views
inserting colored properties into files
when it comes to the echo -e command, of course you can do a lot with it when it comes to printing color text, especially when it comes to making terminal based UIs, but I have one main question, does ...
1
vote
2
answers
77
views
How to loop over a list of extensions to check that files of each type exist?
I have the following directory structure:
main_dir/
│ ├── randstr1.randstr2.tar.gz
│ ├── randstr3.randstr4.tar.gz
│ ├── randstr5.randstr6.tar.gz
│ ├── randstr7.ext2
│ └── randstr8.ext3
...
0
votes
3
answers
83
views
recursively find all directories *primarily* occupied with images
I'm working on a very unorganized archive of a friend spanning many years and with a lot of duplication and compicated structure. I want to split the archive into directories that are primarily ...
0
votes
3
answers
229
views
Append N hexadecimal numbers to a binary file with Bash
I have a Bash script that appends bytes written as hexadecimal values. I use echo to write the bytes and it works
hex="1F"
byte="\x$hex"
echo -en $byte >> "output.bin&...
0
votes
3
answers
150
views
How to display all existing regular files from a text file using one-liner?
How to display all existing regular file names from a text file?
Example:
$ cat file.txt
zzz
xxx/yyy
234 546
"abc def"
--bbb
$ cat file.txt | <one-liner>
zzz
xxx/yyy
In this list ...
0
votes
1
answer
139
views
Use grep to search stdout, without replacing stdout
At the moment, I have this in a wrapper script:
2>&1 ./update.sh | ts | tee -a ./update.log
and this in update.sh:
if apt full-upgrade -y | grep linux-headers
then
echo
echo Need to ...
1
vote
1
answer
38
views
Moving and organizing files with find
I have a folder on a Debian GNU/Linux 12 (bookworm) x86_64 Server used as a NAS/Homelab server with a lot of files from a surveillance camera.
MDAlarm_20240301-091804.jpg
...
MDAlarm_20240316-153813....
0
votes
1
answer
131
views
Access USB device with Bash script
I am using a Raspberry Pi 4 Model B. I am trying to make a script that runs automatically whenever a USB device is plugged in. It will try to read from a text file on the USB device.
This is what I ...
0
votes
2
answers
140
views
How to get the cursor back on the last line of a file
I have a `text file with three numbers and each number separated by new line.
-55
-56
-64
When I open the file I can see the cursor is on the fourth blank line.
I want the cursor to stay on the last ...
-1
votes
2
answers
129
views
Batch rename of files that share the same prefix
I have a list of files on my server with a prefix that I want to de-dupe. These are completely different generated files.
It seems to be generated files with
{Title} - {yyyy-MM-dd}_{random} - {...
3
votes
4
answers
599
views
Copy an evenly spaced subset of files
For example I have files :
file0.txt
file1.txt
file2.txt
....
file100.txt
I would like to copy 5 files in bash, which will produce result :
file0.txt
file19.txt
file39.txt
file59.txt
file79.txt
Edit....
1
vote
2
answers
212
views
Redirect to a filename that will be a variable and contain a command substitution
I'm using nmap to scan a network and then create an XML file that contains the scanned information. I want that XML file to contain the date of the scan so that each file is unique and I can see the ...
-2
votes
1
answer
72
views
unable to evaluate line from file as input aithmetically
So I am writing a bash script that takes in a file with integers on each line and I am writing a function that converts those integers in each line into roman numerals, which i will need to write into ...
0
votes
1
answer
76
views
Can't interact with a file with an apostraphe directly in bash
I have a file titled "I'm Here.mp3" when I try to interact with it with ls, cp, mv, anything, it returns cannot stat "./I'm Here.mp3": No such file or directory.
I tried double ...
0
votes
3
answers
855
views
Use bash to overwrite old file with a new file named according to current date
I am a complete beginner with linux, and need help making a bash script to create a file with a specific date in the file name.
I have a directory called /backups/, in which I would like to create a ...