Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

5 votes
2 answers
510 views
Is there an equivalent of python's enumerate in jq?
I want to get the value *after* a selected item in a list in `jq`. Something like this seems like it would work: ``` jq '. as $list | select(.focused == true) | .id as $id | $list | select(????) ``` One way of doing this would be to enumerate entries like Python - is there a way of doing this. In py...
I want to get the value *after* a selected item in a list in jq. Something like this seems like it would work:
jq '. as $list | select(.focused == true) | .id as $id | $list | select(????)
One way of doing this would be to enumerate entries like Python - is there a way of doing this. In python enumerate takes [x0, x1, x2, x3, ...] -> [(0, x0), (1, x1), ...] . Another way would be an equivalent of itertools itertools.dropwhile
Att Righ (1412 rep)
May 3, 2025, 07:36 PM • Last activity: May 5, 2025, 03:03 PM
0 votes
1 answers
39 views
Why index++ of SWISH++ is so slow?
I'm periodically running `dwww+++` to add to searchable docs what info I add to local drive. It writes "Executing index++" and it runs for minutes, whereas my CPU load is ~2-3% of one core. Why is it so slow and not using full CPU capacity of one core? I'm on Linux Mint 21 based system, my disk is r...
I'm periodically running dwww+++ to add to searchable docs what info I add to local drive. It writes "Executing index++" and it runs for minutes, whereas my CPU load is ~2-3% of one core. Why is it so slow and not using full CPU capacity of one core? I'm on Linux Mint 21 based system, my disk is rather fast.
Martian2020 (1443 rep)
Apr 10, 2025, 09:47 AM • Last activity: Apr 11, 2025, 10:38 AM
44 votes
5 answers
51954 views
/usr/lib/tracker/tracker-store causes very heavy CPU load on Debian "Buster"
After the last upgrade on: Operating System: Debian GNU/Linux buster/sid Kernel: Linux 4.18.0-2-686-pae Architecture: x86 **/usr/lib/tracker/tracker-store** eats a huge load of CPU. PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 7039 nath 20 0 96136 24460 11480 R 100,0 1,3 0:01.76 tracker-sto...
After the last upgrade on: Operating System: Debian GNU/Linux buster/sid Kernel: Linux 4.18.0-2-686-pae Architecture: x86 **/usr/lib/tracker/tracker-store** eats a huge load of CPU. PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 7039 nath 20 0 96136 24460 11480 R 100,0 1,3 0:01.76 tracker-store When I run tracker daemon I get: Miners: 17 Nov 2018, 21:17:06: ? File System - Not running or is a disabled plugin 17 Nov 2018, 21:17:06: ? Applications - Not running or is a disabled plugin 17 Nov 2018, 21:17:06: ? Extractor - Not running or is a disabled plugin I thought I disabled all tracker activities, what is it doing? The fan is going like crazy and a reboot does not improve the situation.
nath (6094 rep)
Nov 17, 2018, 08:06 PM • Last activity: Mar 28, 2025, 01:03 PM
0 votes
0 answers
30 views
Centos is killing share server
I have a `centos 7` based webserver that must access (and display) pdf files from `windows share` server. Problem is that its killing webserwer even when webacess is idle (apache stoped). I have figured out (maybe I'm wrong) that this is most likely gnome problem that has a tracker this is what I di...
I have a centos 7 based webserver that must access (and display) pdf files from windows share server. Problem is that its killing webserwer even when webacess is idle (apache stoped). I have figured out (maybe I'm wrong) that this is most likely gnome problem that has a tracker this is what I did: 1) added exclusion in PRUNEPATCHS (this worked for some time) 2) disabled all search in gnome (by clicking) 3) stoped gnome: service gdm stop 4) sudo tracker stautus say all is indexed, or gives D-Bus / X11 / $DISPLAY error (usually it works from gnome terminal, but not putty terminal) Unplugging server network cable stops problem immediately :). Restarting works for some time.
baron_bartek (113 rep)
Feb 15, 2023, 09:21 AM
2 votes
1 answers
858 views
Indexing files' metadata
Is there a tool that allows to index (search) files based on their [metadata][1] on linux? I've search a bit and found ([here][2]) that there are several tools that allow file indexing on linux: * [Recoll][4] * [mlocate][5] * [locate-rs][6] But it seems like none of these indexes files' metadata (or...
Is there a tool that allows to index (search) files based on their metadata on linux? I've search a bit and found (here ) that there are several tools that allow file indexing on linux: * Recoll * mlocate * locate-rs But it seems like none of these indexes files' metadata (or maybe I just haven't found how in the documentation). This may look as an answer, but the documentation is quite short and I can't figure if that's really what I'm looking for. I found this: GWorkspace , it doesn't look very legit but it states that it does allow metadata based indexing: > GWMetadata is the metadata indexing and search system which includes the live folders functionality. ## My goal To be a bit more precise, I would like to mimic what can (natively) be done on macOs:
# Create a file and set metadata
touch test_file.txt
xattr -w com.apple.metadata:MY_META todo test_file.txt
# Wait a few seconds for the index to update
sleep 5
# Search files that have a given metadata
mdfind "MY_META=todo"
Which returns the path of the file we just created: $(pwd)/test_file.txt. I'm looking for a tool that has a CLI interface because I need to automate things around these few commands.
cglacet (121 rep)
Jun 10, 2022, 06:17 PM • Last activity: Feb 2, 2023, 03:56 PM
0 votes
0 answers
248 views
PostgreSQL: indexes and partitions
I have a PostgreSQL database and I noticed a weird behaviour while working with indexes and partitions. The engine version is 10.21. Now, I have a table with this structure: ``` guid varchar(50) PK guid_a varchar(50) data text part_key varchar(2) ``` There are other columns but they are irrelevant....
I have a PostgreSQL database and I noticed a weird behaviour while working with indexes and partitions. The engine version is 10.21. Now, I have a table with this structure:
guid varchar(50) PK
guid_a varchar(50)
data text
part_key varchar(2)
There are other columns but they are irrelevant. The query I have to run on this table looks like this'
select * from mytable where guid_a = 'jxxxxx-xxxxxxx' and data like '%7263628%';
Let me explain a things: The column guid_a contains a code that identifies a person in the format: 'jxxxx-xxxxxxx' where 'x' are numbers. The first two digits goes from 00 to 99, so, for example:
j01xxx-xxxxxx
j02xxx-xxxxxx
...
j99xxx-xxxxxx
I created an index on this column and then I also created an index using trgm module on the data column. Launching the query I get a giant improvement on the performance. Everything's good until now. I also decided to use partitions (the table has **6.4 million records**) and I created 99 partitions (by list) on the column part_key, which contains the first two digits only of the guid_a value. I obtained 99 partitions with each an average of 65 thousand rows. Each partition has the same indexes I talked about before. Improved the performance again. Obviously le query has another condition for the part_key, so that the engine knows which partition should query. Now the weird stuff. I removed the trgm index on the table without the partitions and, surprise surprise: it's faster. Even faster than the partitioned table. Even removing the trgm indexes on the partitioned table. What I noticed on the explain is that the query on the non-partitioned table is forcing the engine go for a index scan only (shouldn't then also make another scan for the second condition on the data table?). On the partitioned table, on the other hand, it goes for the hitman index scan, then it does a heap scan and then an append. This apparently costs more than indexing all the 6.4 million rows. I made different tests with different values but same results. **Performance**: On average: 11 ms on the partitioned table 9 ms on the non-partitioned table with one index only on the guid_a 20 ms on the non-partitioned table with two indexes, the second on the data column using trgm. What's going on here?
Federico Loro (1 rep)
Jan 20, 2023, 07:03 PM
1 votes
2 answers
285 views
Subtract with previous index where index is not a number using awk
i would like to subtract values from previous values but a condition must be satisfied. File: 2022-02-01 01:00:00|abc|2001|5 2022-02-01 01:00:00|abc|2002|10 2022-02-01 01:01:00|abc|2001|6 2022-02-01 01:01:00|abc|2002|11 2022-02-01 01:02:00|abc|2001|10 2022-02-01 01:02:00|abc|2002|11 2022-02-01 01:02...
i would like to subtract values from previous values but a condition must be satisfied. File: 2022-02-01 01:00:00|abc|2001|5 2022-02-01 01:00:00|abc|2002|10 2022-02-01 01:01:00|abc|2001|6 2022-02-01 01:01:00|abc|2002|11 2022-02-01 01:02:00|abc|2001|10 2022-02-01 01:02:00|abc|2002|11 2022-02-01 01:02:00|abc|2003|2 Desired output: 2022-02-01 01:00:00|abc|2001|5 2022-02-01 01:00:00|abc|2002|10 2022-02-01 01:01:00|abc|2001|1 2022-02-01 01:01:00|abc|2002|1 2022-02-01 01:02:00|abc|2001|4 2022-02-01 01:02:00|abc|2002|0 2022-02-01 01:02:00|abc|2003|2 I tried with awk but couldnt reach the previous index to subtract the value awk -F"|" 'BEGIN{OFS="|"}{a[$1,$2,$3]=$4}END{for (i in a) print i, a[i]-a[i-1] }' file
ammar (87 rep)
Oct 26, 2022, 08:26 PM • Last activity: Oct 29, 2022, 07:01 PM
0 votes
1 answers
4988 views
Awk substr index 0
I just discovered that `substr()` in awk accepts either 0 or 1 as the initial index in a string. I tested this in Gawk 5.1.0 and MacOS awk 20070501. awk 'BEGIN {print substr("abcd", 0, 1)}' outputs "a", as does awk 'BEGIN {print substr("abcd", 1, 1)}' and awk 'BEGIN {print substr("abcd", 2, 1)}' out...
I just discovered that substr() in awk accepts either 0 or 1 as the initial index in a string. I tested this in Gawk 5.1.0 and MacOS awk 20070501. awk 'BEGIN {print substr("abcd", 0, 1)}' outputs "a", as does awk 'BEGIN {print substr("abcd", 1, 1)}' and awk 'BEGIN {print substr("abcd", 2, 1)}' outputs "b" just to prove that nothing's obviously wrong. I didn't see anything in the man pages or the Gawk info file other than mentions of 1-indexing. For consistency with the documentation and with the fact that index() returns 1 for the first position and 0 for no match, it would be good policy to always use 1. My question is why is this duality the case? Also, is it documented somewhere? Are there other awk implementations that do this?
Dennis Williamson (6780 rep)
Jun 28, 2022, 11:34 PM • Last activity: Jul 1, 2022, 10:48 AM
0 votes
1 answers
199 views
Is it possible to integrate pdfgrep into nemo search?
I often find myself looking for PDF documents. Luckily, I found pdfgrep that really does a great job at finding PDF documents by content. Following command lets me search for documents that have my search word on the first page ```shell pdfgrep -irl --page-range=1 2>/dev/null 'mysearchword' ``` Is i...
I often find myself looking for PDF documents. Luckily, I found pdfgrep that really does a great job at finding PDF documents by content. Following command lets me search for documents that have my search word on the first page
pdfgrep -irl --page-range=1 2>/dev/null 'mysearchword'
Is it possible to integrate this command into the Nemo file manager search?
Charles David Mupende (3 rep)
Dec 8, 2021, 01:22 PM • Last activity: Dec 8, 2021, 02:54 PM
3 votes
1 answers
498 views
Index and search a directory
I have a directory tree containing many text-files. I would like to index the full-text of all these files (ignoring files with certain file-extensions), so that I can quickly search thorugh all of them. I do not want to index my whole Home directory, or the whole system. I just want to index this p...
I have a directory tree containing many text-files. I would like to index the full-text of all these files (ignoring files with certain file-extensions), so that I can quickly search thorugh all of them. I do not want to index my whole Home directory, or the whole system. I just want to index this particular directory. The index should update continuously, automatically detecting changes in the files inside. What tool can I use for this?
a06e (1817 rep)
Apr 23, 2018, 05:08 PM • Last activity: Aug 20, 2021, 08:06 PM
1 votes
1 answers
3321 views
Exclude directories for du command / Index all files in a directory
My goal is rather simple: I want to create a small database of all files/directories within a big directory. After looking for a tool suited I couldn't find anything but the good ol' `du`. I figured out that I should use `-b` if I want the number of bytes the files actually have and to use `-a` to l...
My goal is rather simple: I want to create a small database of all files/directories within a big directory. After looking for a tool suited I couldn't find anything but the good ol' du. I figured out that I should use -b if I want the number of bytes the files actually have and to use -a to list all files. Great. Now here's the problem: I do not want to include directories in du's output. I would like to have the output like this per file: sizefilename so I can convert this to CSV or some kind of database. The problem with it containing directories would be that I wouldn't know how to separate directories from files after when I convert/import it to a database and I don't want to end up having files accidentally as directories or vice-versa. I also don't want to end up accidentally counting too much total usage space because when I sum up all files in a directory I already get the whole directory's size, if I add the size of the entire directory on top of that it would be too much. Here is why I don't want to use find -type f... (test directory with 38k files in total, the real one has millions) $ time find -mindepth 1 -type f -exec du -sb {} > /dev/null \; real 0m45.631s user 0m25.807s sys 0m18.946s $ time du -ab > /dev/null real 0m0.154s user 0m0.057s sys 0m0.096s **I'm open to suggestions of any other way to achieve my initial goal.** I just need a way in the end to "browse" directories and see their sizes (and the sizes of the files they contain) without actually having the filesystem in question mounted. (So kinda like an "offline" baobab you might say)
confetti (2134 rep)
Dec 26, 2020, 05:26 AM • Last activity: Dec 27, 2020, 09:38 AM
0 votes
1 answers
173 views
Print only files, directories containing files and empty directories
I am trying to index some LTO tapes (and some hard disks as well) and would like a simple output, stored in a text file. Something like the example below: ... /home/norg/Desktop/empty\ dir/ /home/norg/Documents/file.txt ... The "empty dir" folder is, of course, an empty folder. Notice how folders li...
I am trying to index some LTO tapes (and some hard disks as well) and would like a simple output, stored in a text file. Something like the example below: ... /home/norg/Desktop/empty\ dir/ /home/norg/Documents/file.txt ... The "empty dir" folder is, of course, an empty folder. Notice how folders like "Desktop" and "Documents" are only printed because they have contents inside them. In other words, /home/norg/Desktop/ would never be printed, unless it were empty. I've tried things like ls -RFad /home/norg/ and some find syntaxes to varying success. The trickiest part is having the empty directories printed, but not the full ones. I hope this makes sense. Thanks. Another thing to mention, I would really prefer this to work in one go, as I will be using this with tape and want to have as little reads as necessary to reduce wear.
norglis (1 rep)
Aug 28, 2020, 10:21 PM • Last activity: Aug 29, 2020, 09:39 PM
6 votes
2 answers
15699 views
bash array of arrays
Trying to write some nested loop, and I'm not getting how to write it. Perhaps I'm looking in a wrong direction but what I'm trying to write is: declare -a bar=("alpha" "bravo" "charlie") declare -a foo=("delta" "echo" "foxtrot" "golf") declare -a subgroups=("bar" "foo") So then I would like to iter...
Trying to write some nested loop, and I'm not getting how to write it. Perhaps I'm looking in a wrong direction but what I'm trying to write is: declare -a bar=("alpha" "bravo" "charlie") declare -a foo=("delta" "echo" "foxtrot" "golf") declare -a subgroups=("bar" "foo") So then I would like to iterate the subgroups (in the future more *bar*s and *foo*s will come), and inside them iterate them as they can have a different number of elements. The desired output would be something like: group name: bar with group members: alpha bravo charlie working on alpha of the bar group working on bravo of the bar group working on charlie of the bar group group name: foo with group members: delta echo foxtrot golf working on delta of the foo group working on echo of the foo group working on foxtrot of the foo group working on golf of the foo group The closes code I've wrote seems fail in the *bar* and *foo* arrays and its expansion with the elements on each set. for group in "${subgroups[@]}"; do lst=${!group} echo "group name: ${group} with group members: ${!lst[@]}" for element in "${!lst[@]}"; do echo -en "\tworking on $element of the $group group\n" done done And the output is: group name: bar with group members: 0 working on 0 of the bar group group name: foo with group members: 0 working on 0 of the foo group
srgblnch (243 rep)
Oct 7, 2019, 10:51 AM • Last activity: Oct 22, 2019, 06:09 PM
1 votes
1 answers
1498 views
for loop with indices
Let's suppose I have the following loop: for i in {1..3} do mkdir $i done Since I have many other loops in the main code and I am going to change regularly the size of the sequence, I would like to define the `start` and `end` of the loop and use these variables in the for loop(s). I tried this with...
Let's suppose I have the following loop: for i in {1..3} do mkdir $i done Since I have many other loops in the main code and I am going to change regularly the size of the sequence, I would like to define the start and end of the loop and use these variables in the for loop(s). I tried this without success: start=1; end=1; for i in {$start..$end} do mkdir $i done Any suggestion?
aaaaa (141 rep)
Jul 1, 2019, 09:48 AM • Last activity: Jul 1, 2019, 09:52 AM
3 votes
1 answers
763 views
Does sort --unique -k drop duplicates in original order?
I'm doing a unique sort on a concatenated set of index files where the first column will sometimes change between each index and the second column will be a key value (actually hex addresses). Each indexN file iteration records addresses that changed since the prior one -- if address 0xaa11 exists i...
I'm doing a unique sort on a concatenated set of index files where the first column will sometimes change between each index and the second column will be a key value (actually hex addresses). Each indexN file iteration records addresses that changed since the prior one -- if address 0xaa11 exists in index3, in the merged+sorted output it should replace the 0xaa11 address references from index1 and index2. The question is, can I do this type of merge *reliably* with a tool like GNU sort if I merely pipe each source index to sort -u in a certain order? For example, pipe indexes newest to oldest: cat index3 index2 index1 | sort -u -k 2,2 When I test this, it does seem to preserve the lines from index3 containing addresses that also appear in index2 and index1, while removing those duplicate references coming from index2 and index1. But will that *always* be the case? The sort man page is vague about this: -u --unique output only the first of an equal run I don't know enough about GNU sort's algorithms to predict whether lines with matching keys will always sort into the same order in which their source files were concatenated (e.g. the order they appear in the source stream). But I do know that sort algorithms don't always work in a linear fashion. That's why I'm looking for clarification of what sort's documentation seems to imply.
tasket (225 rep)
Nov 22, 2018, 06:02 AM • Last activity: Jun 8, 2019, 09:22 AM
2 votes
1 answers
232 views
Read Text List into Dynamic array?
Trying to automate some work stuff and this includes many folder generations but and I was thinking of using a dynamic array to do this, let me know how this sounds. First Part of my Script is to export a directory list using the: ls /home/USER/Downloads/ > "/home/USER/Desktop/scripts/FolderList.txt...
Trying to automate some work stuff and this includes many folder generations but and I was thinking of using a dynamic array to do this, let me know how this sounds. First Part of my Script is to export a directory list using the: ls /home/USER/Downloads/ > "/home/USER/Desktop/scripts/FolderList.txt" and it gives the output as expected: Folder With Some Long Title Folder With Another Long Title In this example I only gave (2) but there could be upwards of 1500+ folders and I have already written the commands to create the other folders on my server and name them automatically based off the original folder name, but the problem I have is I want my scripts to index thru all the folders and preform my commands (there are about 8 that are mostly string manipulations and such). So I was thinking of getting the count of the number of items in the Directory then write them to the text file mentioned above, then using a FOR-Loop to run that number of times that will contain my 8 or so commands? any thoughts or better ideas? I Can get the count using: wc -l FolderList.txt | awk '{ print $1 }' But I'm not sure how to create or manage a Dynamic Array and use it with the for-loop to index thru my commands. here is some of the script that goes with it currently some commented out for modular testing: #TestString="Customer Info (YEAR) [PMNAME] [OWNERNAME] [EETYPE]" cd "/home/USER/Downloads/" ls /home/USER/Downloads/ > "/home/USER/Desktop/scripts/FolderList.txt" wc -l FolderList.txt | awk '{ print $1 }' #CUSTINFO=${TestString/(*)*} #YEAR=$(grep -o '(.*)' <<<"$TestString") #RESO3=$(grep -o '\[.*\]' <<<"$TestString") #RESO2=${RESO3//\[PMNAME\]/} #RESO_FINAL=${RESO2//\[EETYPE\]/} #FULL_NAME=$TITLE_FINAL$CUSTINFO$YEAR #mv "/home/USER/Downloads/$DOWNLOAD_NAME" "/home/USER/Downloads/$FULL_NAME" #for f in */* ;do fp=$(dirname "$f"); ext="${f##*.}" ; mv "$f" "$fp"/"$fp"."$ext" ;done
user354662 (35 rep)
May 30, 2019, 03:25 AM • Last activity: May 30, 2019, 06:57 AM
5 votes
2 answers
3920 views
What tools can I use for PDF indexing?
In our working group we used Recoll on a Ubuntu PC to index all the PDF. For a while we moved everything to a Redhat server. Is there a Recoll alternative which doesn't requires a GUI adn support searching through a web interface?
In our working group we used Recoll on a Ubuntu PC to index all the PDF. For a while we moved everything to a Redhat server. Is there a Recoll alternative which doesn't requires a GUI adn support searching through a web interface?
Mokus (239 rep)
May 26, 2014, 08:07 AM • Last activity: Sep 15, 2018, 02:09 PM
2 votes
0 answers
796 views
Tracker-extract and Tracker-store processes consuming huge Amount of RAM
I am using Arch Linux, kernel 3.16. From last one week my two processes tracker-extract and tracker-store are taking too much RAM. It results in hangup of system once in every 2 hours. **tracker-extract taking 300 MB and tracker -store taking 2 GB RAM.** I want to know what are these tracker process...
I am using Arch Linux, kernel 3.16. From last one week my two processes tracker-extract and tracker-store are taking too much RAM. It results in hangup of system once in every 2 hours. **tracker-extract taking 300 MB and tracker -store taking 2 GB RAM.** I want to know what are these tracker processes and what are their work. If i kill them does this effect in system performance ? What are the ways to kill them permanently so that I can get rid of these two processes? Please help me.
Ankith (29 rep)
Nov 4, 2014, 04:32 PM • Last activity: Mar 25, 2018, 10:25 PM
0 votes
2 answers
381 views
Is it possible to fake a SMB network mounted folder as a native folder?
I have an HDD hooked up to a linux TV receiver (Vu Solo) with a lot of movies in one folder. This device and my (Synology) NAS are in the same local network. The NAS contains a media indexing service that scans specific native folders (e.g. /video) on the NAS. So far I have shared the folder on the...
I have an HDD hooked up to a linux TV receiver (Vu Solo) with a lot of movies in one folder. This device and my (Synology) NAS are in the same local network. The NAS contains a media indexing service that scans specific native folders (e.g. /video) on the NAS. So far I have shared the folder on the receiver (containing the movies) via SMB and mounted it in within the /video folder on the NAS in a separate folder. Unfortunately, the indexing service of the NAS ignores that mounted folder. My guess is I would have to pretend somehow that this is not a mounted directory but just another native folder on the NAS. Is there any chance of doing this? Thank you for your help in advance!
uxfelix (101 rep)
Jan 16, 2018, 06:11 AM • Last activity: Jan 16, 2018, 08:04 PM
1 votes
1 answers
90 views
How does Ubuntu's indexation work on a virtual machine?
I have read on [https://help.ubuntu.com/community/FindingFiles][1] the following sentence: >Thankfully my computer indexes all my files every night while I sleep and I can search just the index, which will take only a few seconds, even on as an expansive a filesystem as mine. And I was just wonderin...
I have read on https://help.ubuntu.com/community/FindingFiles the following sentence: >Thankfully my computer indexes all my files every night while I sleep and I can search just the index, which will take only a few seconds, even on as an expansive a filesystem as mine. And I was just wondering how does it work on a virtual machine? Does it occur even though the VM is powered off?
DRz (113 rep)
Feb 24, 2016, 03:22 PM • Last activity: Apr 15, 2017, 08:55 AM
Showing page 1 of 20 total questions