G
G
Gasgolder2019-12-22 13:47:35
linux
Gasgolder, 2019-12-22 13:47:35

How to list folders?

There is a directory in which there is a file with a list of IDs - id_list.txt and a bunch of folders, each of which has a config.ini file and logs (there may not be logs, not every folder has them) You need to write a script or a command that will output a list of folder names in config.ini which specify a port missing in the id_list file. Here is a figurative path to the config.ini file /mnt/d/logs/folder name/config.ini Path to the id_list.txt file /mnt/d/logs/id_list.txt
Here is the content of the config.ini file (the port parameter in each folder is different )

[Application]
password = 1231dase34
contract = 111111111111111111
queue_max_length = 300
log_level = 5
log_file = /var/log
<b>port = 11916</b>
# включить личный кабинет
db_history = on
db_file = /var/db
# замена расширения файла с записью
record_replace_old = ".3gp"
record_replace_new = ".mp3"
# замена http на https
record_replace_old = "http://"
http_history=0

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
AUser0, 2019-12-22
@Gasgolder

Well, like this, save to some 'script.sh', run through '/bin/sh script.sh':

#!/bin/sh
for FILE in $(find /mnt/d/logs -name config.ini); do
  PORT=$(grep -oP "^port += +\K([0-9]+)" $FILE)
  FND=$(grep "^${PORT}$" /mnt/d/logs/id_list.txt)
  if [ "$FND" == "" ]; then
    echo $FILE
  fi
done

K
ky0, 2019-12-22
@ky0

1. Pull yourself together
2. Write a script
If there are any difficulties with these points, go to the next tab .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question