Skip to main content

All Questions

Tagged with
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
2 votes
3 answers
613 views

Move files to directory according to the content pattern matching

I would like to move files in existing directory files containing specific content to an existing or new directory and subdirectory by writing a script called fruit in ~/bin that moves them to dir/...
yosif's user avatar
  • 21
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
0 votes
1 answer
846 views

File is having lots of special characters. How to replace?

I have a file with record like: CENTURY®KETTLEBELLS COLEMANTT40°BAG AlphaPro2¾TDLE Lot™Stretch M6×30 It shows normally in notepad files but in terminal when i cat it, it shows: CENTURY▒KETTLEBELL ...
Amin's user avatar
  • 13
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
2 votes
2 answers
201 views

How do I delete all directories with a certain file type in them?

I'm writing a command line script to 'unpack' folders with .svg files from downloads. I've copied the required files to a specific directory and now I need to delete all the directories with .svg ...
MetricSystemAdvocate's user avatar
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
2 votes
2 answers
139 views

How to find same filename but different content

I am trying to find the textfiles that have the same name but contain different content from two different directories. The following is my code but it keeps crashing here cati=`ls $1 | cat $i` ...
newuserr's user avatar
2 votes
3 answers
3k views

How can I reliably determine if a file is an image file? [duplicate]

Currently I'm using the following command: file image.jpg | cut -d " " -f 2 So far so good. It works on a file without an image extension too. So, I was wondering if there's another way to do this? I ...
Quatrivius's user avatar
-1 votes
3 answers
952 views

How do I create always 4 digit sequentially numbered and named file with shell script

I'm trying to create multiple *.txt files with 4-digit numerical names with leading zeros when needed. Script needs to stop when MAX varialbe is reached. This is using /bin/sh (not bash) but any ...
almadinedotnet's user avatar
1 vote
2 answers
149 views

Generate the output of the file in the next line

I have 3 files ex- abc.txt, def.txt & xyz.txt. I've generate one shell script where I want to content of these 3 files should appear line wise like as below- abc ---- 1 2 3 4 5 6 7 def ----...
Md Wasi's user avatar
  • 123
2 votes
1 answer
103 views

I have an issue with a script that does file manipulation

Ive been working on a script that instantaneously detects files created in the Downloads directory then sorts them based on file extension. The issue with this however is that when downloading a file ...
mr Stap's user avatar
  • 61
12 votes
6 answers
17k views

Checking for the existence of multiple directories

I want to check for the existence of multiple directories, say, dir1, dir2 and dir3, in the working directory. I have the following if [ -d "$PWD/dir1" ] && [ -d "$PWD/dir2" ] && [ -...
Elegance's user avatar
  • 123
1 vote
2 answers
72 views

Comparison of two values from two list

I am trying to compare two strings. One value is coming from iptables and the other is from a file where I saved previous records. I want to identify if there is a new user appear in iptables. If so ...
Sachith Muhandiram's user avatar

15 30 50 per page