Sample Header Ad - 728x90

Unix & Linux Stack Exchange

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

Latest Questions

0 votes
1 answers
28 views
Storing the iterations of the Receiver (or node) number and RSSI value into an CSV file
I'm quite new to Linux. Recently, I've been able to create a bash script that allows me to obtain the RSSI of the receivers (or node) with a running iteration. How can I store these results in an CSV file with a format such as: Node RSSI ... [...,...] ... [...,...] Here is what the output looks like...
I'm quite new to Linux. Recently, I've been able to create a bash script that allows me to obtain the RSSI of the receivers (or node) with a running iteration. How can I store these results in an CSV file with a format such as: Node RSSI ... [...,...] ... [...,...] Here is what the output looks like when running the file: bash test.sh -l 170,171 -k 2 === Iteration 1 === Node RSSI ------ ---------- 170 -43 dBm 171 -43 dBm === Iteration 2 === Node RSSI ------ ---------- 170 -43 dBm 171 -44 dBm
Trinh Dat (1 rep)
Jul 25, 2025, 08:57 PM • Last activity: Jul 25, 2025, 09:33 PM
-4 votes
1 answers
71 views
file format help
input file ``` Env Status (PRE) tomcat1 |-- Status : Running | Host : VVV | pid/s : 7427 |-- Status : Running | Host : VVV | pid/s : 489 |-- Status : Running | Host : VVV | pid/s : 964 tomcat2 |-- Status : Running | Host : nn | pid/s : 27447 tomcat3 |-- Status : Running | Host : vv | pid/s : 31739 s...
input file
Env Status (PRE)

tomcat1
  |-- Status : Running   |   Host : VVV   |   pid/s : 7427
  |-- Status : Running   |   Host : VVV   |   pid/s : 489
  |-- Status : Running   |   Host : VVV   |   pid/s : 964

tomcat2
  |-- Status : Running   |   Host : nn   |   pid/s : 27447

tomcat3
  |-- Status : Running   |   Host : vv   |   pid/s : 31739

ssss
  |-- Status : Stopped   |   Host : bbb   |   pid/s : 29137
  |-- Status : Running   |   Host : vvv   |   pid/s : 26365
output file
Env Status (PRE)


tomcat1|-- Status : Running   |   Host : VVV   |   pid/s : 7427
tomcat1|-- Status : Running   |   Host : VVV   |   pid/s : 489
tomcat1|-- Status : Running   |   Host : VVV   |   pid/s : 964
tomcat2|-- Status : Running   |   Host : nn   |   pid/s : 27447
tomcat3|-- Status : Running   |   Host : vv   |   pid/s : 31739
ssss|-- Status : Stopped   |   Host : bbb   |   pid/s : 29137
ssss|-- Status : Running   |   Host : vvv   |   pid/s : 26365
Rabindra Panigrahi (5 rep)
Jul 23, 2025, 08:01 PM • Last activity: Jul 24, 2025, 04:09 AM
0 votes
2 answers
62 views
In a text file, finding and deleting lines including (e.g.) "#', or a word?
I am using Ubuntu Linux and Mageia Linux... I wish to do the following: in a text file (sample.txt), find and delete every line comprising the symbol '#' (or '?') or a specific word (e.g. 'mobile') Any idea how to start ? Thanks a lot Vincent
I am using Ubuntu Linux and Mageia Linux... I wish to do the following: in a text file (sample.txt), find and delete every line comprising the symbol '#' (or '?') or a specific word (e.g. 'mobile') Any idea how to start ? Thanks a lot Vincent
Vinz M (11 rep)
Jun 16, 2025, 12:16 PM • Last activity: Jun 18, 2025, 05:54 AM
2 votes
2 answers
8223 views
What's the best way to display tabs/spaces in my plain text files
I have a file that unfortunately contains both tabs and spaces. How do I display them so I know if a particular space is actually tab or space?
I have a file that unfortunately contains both tabs and spaces. How do I display them so I know if a particular space is actually tab or space?
CuriousMind (289 rep)
Oct 19, 2015, 04:15 PM • Last activity: Jun 10, 2025, 06:20 AM
2 votes
1 answers
375 views
Cannot open an .mbox file with neomutt (although it works with mutt)
Cannot open an .mbox file with mutt I want to open a 10GB `.mbox` file that I downloaded from my gmail account. When I use the command ``` neomutt -f 10GB_mboxfile.mbox ``` neomutt takes 10-20 seconds to open and when finally opened, there is no file listed in the the application. I have the followi...
Cannot open an .mbox file with mutt I want to open a 10GB .mbox file that I downloaded from my gmail account. When I use the command
neomutt -f 10GB_mboxfile.mbox
neomutt takes 10-20 seconds to open and when finally opened, there is no file listed in the the application. I have the following dummy .mbox (which I modified from a gmail mbox file):
From 9999999999999999@xxx Tue Mar 09 17:00:00 +0500 2019  
X-GM-THRID: 99999999999999999
X-mail-Labels: Archived,Sent,Opened
MIME-Version: 1.0
Date: Tue, 09 Mar 2019 17:00:00 +0500
Message-ID: 
Subject: THETITLE
From: My Name 
To: destination@mail.com
Content-Type: multipart/alternative; boundary="0000000000009999999999999"

--0000000000009999999999999
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable


ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ da=
s ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ

--0000000000009999999999999
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ= ZZ das ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ= > --0000000000009999999999999--
I am trying to open it with neomutt as follows:
neomutt -f themboxfile.mbox
neomutt opens but then no message is listed in the app. How is it possible to open this file with neomutt? (Although opening the same file works with mutt...) **EDIT** Beside the answer below I had a too old version: the apt get install neomutt on Ubuntu LTS 22.04 installed the version 20211029. I uninstalled neomutt and re-installed it with nix package manager. it installed NeoMutt 20231221 which worked without problem.
ecjb (475 rep)
Jun 8, 2024, 12:57 PM • Last activity: Mar 2, 2025, 09:35 AM
17 votes
9 answers
4591 views
How to process an x-column text file to get a y-column one?
I have a text file: a aa aaa b bb bbb c cc ccc d dd ddd e ee eee f ff fff g gg ggg h hh hhh i ii iii j jj jjj How can I process it and get a 2 column file like this: a aa aaa b bb bbb c cc ccc d dd ddd e ee eee f ff fff g gg ggg h hh hhh i ii iii j jj jjj Or a three column file like this: a aa aaa b...
I have a text file: a aa aaa b bb bbb c cc ccc d dd ddd e ee eee f ff fff g gg ggg h hh hhh i ii iii j jj jjj How can I process it and get a 2 column file like this: a aa aaa b bb bbb c cc ccc d dd ddd e ee eee f ff fff g gg ggg h hh hhh i ii iii j jj jjj Or a three column file like this: a aa aaa b bb bbb c cc ccc d dd ddd e ee eee f ff fff g gg ggg h hh hhh i ii iii j jj jj I prefer to get awk solution but other solutions are welcomed too.
Just a learner (2022 rep)
Sep 8, 2016, 11:05 AM • Last activity: Jan 10, 2025, 03:49 PM
1 votes
2 answers
269 views
Extracting table of contents from PDFs
I have a reasonably large personal library with books in various formats. I have tried to organize their metadata, including a text field containing the tables of contents. At the moment I am using the 'Area Text Selection' feature from my document reader to copy the text. Doing this for DJVUs with...
I have a reasonably large personal library with books in various formats. I have tried to organize their metadata, including a text field containing the tables of contents. At the moment I am using the 'Area Text Selection' feature from my document reader to copy the text. Doing this for DJVUs with djview yields nicely formatted tables of contents, like this:
CONTENTS
1. EXPERIMENTS
1.1. The definition of an experiment ..... 1
1.2. Algebras of events as Boolean algebras .... 6
1.3. Operations with experiments ...... 9
1.4. Canonical representation of polynomials of events . . 12
....
I emphasize that all I did was drag my mouse across the page and click "Copy Text". If I try this with a PDF the structure is completely lost and I have to spend some time cleaning up the text selection, moving the page and section numbers around. I might get something like this:
Table of Contents
I
 Introduction
1
 Introduction
1.1
 Table of Contents
1.2
 Acknowledgments
1
3
3
6
II
....
I am looking for a PDF reader that can similarly copy the text but with the 'structure' preserved. The fact that DJVU readers have this capability tells me this ought to be possible. Note: I am not talking about extracting ToCs from the bookmarks: many of my PDFs don't have any. I'd also like to avoid a CLI tool that has to process the entire file: I just want it to pick the text I select, but with the newlines and overall structure intact.
Luke (13 rep)
Dec 16, 2024, 03:42 PM • Last activity: Dec 16, 2024, 05:00 PM
3 votes
2 answers
5880 views
How can I replace ^I into tab spaces in vim editor for .java file?
When I open my .java file in vim, I could see a couple of lines prefixed with one / more `^I` characters. It looks like tabs in Eclipse that has got converted into `^I`. I would like to replace a single `^I` into spaces with 4 characters. E.g `^I^I^I^IList rulePackagesHistory = result.getHistory();`...
When I open my .java file in vim, I could see a couple of lines prefixed with one / more ^I characters. It looks like tabs in Eclipse that has got converted into ^I. I would like to replace a single ^I into spaces with 4 characters. E.g ^I^I^I^IList rulePackagesHistory = result.getHistory(); How can do that in vim editor?
user648330 (33 rep)
Aug 21, 2014, 07:36 AM • Last activity: Dec 16, 2024, 09:05 AM
52 votes
3 answers
5062 views
Purpose of “ASCII text, with overstriking” file format
After downloading the source code for Bash, I was browsing through the `doc` directory and came across the following files: * [`bash.1`](http://git.savannah.gnu.org/cgit/bash.git/tree/doc/bash.1) is a regular [troff](https://en.wikipedia.org/wiki/Troff) file used to build the *man page*. * [`bash.0`...
After downloading the source code for Bash, I was browsing through the doc directory and came across the following files: * [bash.1](http://git.savannah.gnu.org/cgit/bash.git/tree/doc/bash.1) is a regular [troff](https://en.wikipedia.org/wiki/Troff) file used to build the *man page*. * [bash.0](http://git.savannah.gnu.org/cgit/bash.git/tree/doc/bash.0) is like a plain text version of the man page – only that it has the [^H backspace control character](https://en.wikipedia.org/wiki/Backspace#.5EH) liberally distributed throughout it. These control characters are not displayed in the representation provided by the Git web interface but the [actual file can be downloaded](http://git.savannah.gnu.org/cgit/bash.git/plain/doc/bash.0) and examined in text editor such as Vim. Running the file command on bash.0 prints the following output: bash.0: ASCII text, with overstriking I’ve never come across this file format before and I was wondering what its purpose is and how it’s used. Searching the Web for the phrase *“ASCII text, with overstriking”* hasn’t been very enlightening.
Anthony Geoghegan (13511 rep)
Apr 6, 2016, 10:36 AM • Last activity: Dec 11, 2024, 08:46 PM
4 votes
6 answers
10290 views
Use sed command to check if a particular line exists, if not, add it
I want to add more terminals to the file `/etc/securetty`. More specifically I would like to add `pts/n`, where `n` is in the range `0-9`, if it does not exist. Is this possible through `sed` command? The following is how the contents of my `/etc/securetty` are: # Local X displays (allows empty pass...
I want to add more terminals to the file /etc/securetty. More specifically I would like to add pts/n, where n is in the range 0-9, if it does not exist. Is this possible through sed command? The following is how the contents of my /etc/securetty are: # Local X displays (allows empty passwords with pam_unix's nullok_secure) pts/0 pts/1 pts/2 pts/3 I tried some thing like: sudo sed '+pts/3+a pts/4' /etc/securetty which gives the following error: sed: -e expression #1, char 3: extra characters after command
skrowten_hermit (791 rep)
Apr 12, 2017, 11:06 AM • Last activity: Nov 24, 2024, 04:55 AM
0 votes
3 answers
239 views
How to edit a string matching a pattern in a specific field on the condition another string is not present on the same line
I need to edit the string "NA" to "Na" only if it is in the 6th field of a file. I can currently achieve this with: awk '{gsub("NA","Na",$6)}1' $filename However I need the additional condition that this wont occur if the string "HEM" is in the same line. For example I would want the following line...
I need to edit the string "NA" to "Na" only if it is in the 6th field of a file. I can currently achieve this with: awk '{gsub("NA","Na",$6)}1' $filename However I need the additional condition that this wont occur if the string "HEM" is in the same line. For example I would want the following line to stay the same: 7353 NA 5.4433 24.4404 -3.0784 NA 456 HEM Lastly, the above command removes the extra padding between fields. If there is a command that can accomplish this without changing the spacing between fields that would be awesome, but this feature is not necessary. I think this could be done with a while read through each file and printing each line, and only editing with an if statement, but I am trying to avoid something clunky like that. I feel like this one is a tall order to do in a simple fashion, but I would be super appreciative if any unix wizards know how. Thanks!
CPC_92 (3 rep)
Oct 29, 2024, 11:42 PM • Last activity: Nov 1, 2024, 08:08 PM
8 votes
4 answers
3528 views
Wrap and indent text using coreutils
### Short version I would like to create a tabular display of multiline text, similar to the following: all Build all targets document Create documentation of source files in the subfolders `src` and `script`, and write it to `man` test Run unit tests At the moment, my input for this looks as follow...
### Short version I would like to create a tabular display of multiline text, similar to the following: all Build all targets document Create documentation of source files in the subfolders src and script, and write it to man test Run unit tests At the moment, my input for this looks as follows, but this can of course be changed: all---Build all targets document---Create documentation of source files in the subfolders src and script, and write it to man test---Run unit tests I’ve tried achieving this with a combination of awk and wrap/pr but while the line wrapping works, the indentation doesn’t. Here’s my current approach: … | awk -F '---' "{ printf '%-10s %s\n', $1, $2 }" \ | fold -w $(($COLUMNS - 1)) -s It generates the output all Build all targets document Create documentation of source files in the subfolders src and script, and write it to man test Run unit tests … in other words, the third line isn’t indented as intended. **How can I format the text with a given wrap length and a given hanging indent width?** — Without changing anything else about the text. Bonus: this should work with UTF-8 and escape/control characters. --- ### Background info The goal is to create [self-documenting Makefiles](https://gist.github.com/klmr/575726c7e05d8780505a) . As a consequence, the logic to format and display the code should be small, self-contained, and not rely on separately installed software; ideally, it should work on any system that can execute Makefiles, hence my restriction to (something close to) coreutils. That said, I briefly tried solving the problem using groff but this became too complex very quickly (and OS X groff is and old version that doesn’t seem to support UTF-8). The *original string* that I’m trying to parse and format therefore looks rather as follows: ## Build all targets all: test document ## Run unit tests test: ./run-tests . ## create documentation of source files in the subfolders src and script, ## and write it to man document: ${MAKE} -C src document ${MAKE} -C script document At the moment, this is parsed using a sed script (see link for details) that ignores multiline comments, before being fed to the formatting code posted above.
Konrad Rudolph (3839 rep)
Apr 30, 2016, 12:56 PM • Last activity: Oct 17, 2024, 03:16 AM
0 votes
2 answers
586 views
grabbing username and password hashes from /etc/security/passwd
I have a list of usernames which i need to sync their passwords over to a new server. How would I go about extracting the username and password hash from the /etc/security/passwd file into the below format ``` username:MGURSj.F056Dj ``` The passwd file is in stanza format ``` username: password = MG...
I have a list of usernames which i need to sync their passwords over to a new server. How would I go about extracting the username and password hash from the /etc/security/passwd file into the below format
username:MGURSj.F056Dj
The passwd file is in stanza format
username:
  password = MGURSj.F056Dj
  lastupdate = 623078865
jonske (15 rep)
May 5, 2020, 08:06 AM • Last activity: Oct 15, 2024, 08:12 AM
0 votes
4 answers
181 views
Aligning space separated words in columns
There is a text file, `file.txt`. In there is: abc 01245 def-1 32154 ghi-3 55432 jkl 44121 mno-4 23147 pqr 897044 .... How to format this to an output like this: abc 01245 def-1 32154 ghi-3 55432 jkl 44121 mno-4 23147 pqr 897044 .... Can `awk` do this?
There is a text file, file.txt. In there is: abc 01245 def-1 32154 ghi-3 55432 jkl 44121 mno-4 23147 pqr 897044 .... How to format this to an output like this: abc 01245 def-1 32154 ghi-3 55432 jkl 44121 mno-4 23147 pqr 897044 .... Can awk do this?
user447274 (539 rep)
Oct 13, 2024, 03:35 AM • Last activity: Oct 13, 2024, 04:32 PM
0 votes
3 answers
1139 views
Echo out a specific word in bash
Basically, i have a bunch of commands in bash that are asking my machine the information of it. Like: > host=$(hostname -A) hostname=$(hostname -I) Pub_IP=$(dig +short myip.opendns.com @resolver1.opendns.com) Kernel_Version=$(uname -v | awk -F"Debian" '{print $2}' | cut -d ' ' -f2 | cut -d '-' -f1)...
Basically, i have a bunch of commands in bash that are asking my machine the information of it. Like: > host=$(hostname -A) hostname=$(hostname -I) Pub_IP=$(dig +short myip.opendns.com @resolver1.opendns.com) Kernel_Version=$(uname -v | awk -F"Debian" '{print $2}' | cut -d ' ' -f2 | cut -d '-' -f1) Deb_Version=$(cat /etc/debian_version) I am also echoing it echo $host $hostname $Pub_IP $Kernel_Version $Deb_Version > info.txt What i need to figure out is how i can put | between each of the parameter. So if i look into my info.txt file, it would look something like | debianmachine | output_of_hostname | output_of_Pub_IP | Also, i might be able to do this with print?
TheSebM8 (471 rep)
Mar 22, 2018, 08:10 AM • Last activity: Sep 28, 2024, 06:18 PM
3 votes
1 answers
647 views
The "join" utility reports: file is not sorted, but in fact it is sorted
I have two files `t1` and `t2`. root@localhost:~# root@localhost:~# cat t1 udp UNCONN 0 0 0.0.0.0:68 0.0.0.0:* users:(("dhclient",pid=479,fd=7)) 479 tcp LISTEN 0 128 127.0.0.1:6060 0.0.0.0:* users:(("gggg-ruit",pid=24968,fd=5)) 24968 root@localhost:~# root@localhost:~# cat t2 root 88 0.0 0.0 0 0 ? I...
I have two files t1 and t2. root@localhost:~# root@localhost:~# cat t1 udp UNCONN 0 0 0.0.0.0:68 0.0.0.0:* users:(("dhclient",pid=479,fd=7)) 479 tcp LISTEN 0 128 127.0.0.1:6060 0.0.0.0:* users:(("gggg-ruit",pid=24968,fd=5)) 24968 root@localhost:~# root@localhost:~# cat t2 root 88 0.0 0.0 0 0 ? I< Jan06 0:00 [scsi_tmf_0] root 96 0.0 0.0 0 0 ? I< Jan06 0:00 [ipv6_addrconf] root 24965 0.0 0.2 11592 3004 ? S Jan12 0:00 bash /root/restart_gggg.sh root 24968 0.7 5.2 112488 53472 ? Sl Jan12 30:52 /usr/local/bin/gggg-ruit -singleInstance :44444 I want to join them on the 8th column of t1 and the 2nd column of t2. I already have them in sorted order. Let's prove it. root@localhost:~# awk '{print $8}' t1 479 24968 root@localhost:~# awk '{print $2}' t2 88 96 24965 24968 Now when I join them, I got the following error. root@localhost:~# join -1 8 -2 2 -o 2.1,2.2,1.1,1.2,1.5,1.6,2.11 t1 t2 join: t2:3: is not sorted: root 24965 0.0 0.2 11592 3004 ? S Jan12 0:00 bash /root/restart_gggg.sh root@localhost:~# Why it tells me t2 is not sorted on row 3? As you can see, it's been already sorted on the join column.
Just a learner (2022 rep)
Jan 15, 2020, 01:54 PM • Last activity: Aug 31, 2024, 04:35 AM
13 votes
4 answers
18885 views
How to use Awk to format numbers with a thousands separator
Can anyone tell me how to use the awk command for this statement "the number will contain commas after every three digits. For example, 100000000 will become 100,000,000." I know how to use sed command to obtain this output but I don't know how to use awk, I'm beginner please tell me I'm searching f...
Can anyone tell me how to use the awk command for this statement "the number will contain commas after every three digits. For example, 100000000 will become 100,000,000." I know how to use sed command to obtain this output but I don't know how to use awk, I'm beginner please tell me I'm searching from morning but I didn't get a suitable answer for this so please suggest me best tutorials for learning. sed command to get the above output: echo "100000000" | sed -E 's/([0-9]{3})/,\1/2g'
Error3735 (155 rep)
Dec 13, 2015, 05:51 PM • Last activity: Aug 28, 2024, 05:50 AM
19 votes
5 answers
46898 views
How can I pretty format a JSON file, with all the correct indents and everything?
I have a JSON file on CentOS where all text is on the same line. How can I pretty format it with all the correct indents and everything?
I have a JSON file on CentOS where all text is on the same line. How can I pretty format it with all the correct indents and everything?
dr_ (32068 rep)
May 18, 2018, 01:41 PM • Last activity: Jul 30, 2024, 02:46 PM
1 votes
4 answers
2854 views
Split a string into separate words
I can print a string using echo in bash shell-like `echo "This is a sample string"`. Is there some command I can use as a pipe or some arguments to echo after the string that could result in the following output: ``` This is a sample string ``` Basically split the string and print the words each in...
I can print a string using echo in bash shell-like echo "This is a sample string". Is there some command I can use as a pipe or some arguments to echo after the string that could result in the following output:
This
is
a
sample
string
Basically split the string and print the words each in a new line
dnaiel (131 rep)
Jan 19, 2022, 06:00 PM • Last activity: Jul 9, 2024, 07:31 PM
0 votes
0 answers
41 views
is a cell boldface
I'm looking for a function to determine if a cell is formatted **bold**. I'm using LibreOffice Calc, and for ease of use, I have a range of items to buy and their prices. I want to have a simple method of marking an item as being bought. Rather than highlight the cell, hit F2, Home, and *, e.g., I'd...
I'm looking for a function to determine if a cell is formatted **bold**. I'm using LibreOffice Calc, and for ease of use, I have a range of items to buy and their prices. I want to have a simple method of marking an item as being bought. Rather than highlight the cell, hit F2, Home, and *, e.g., I'd like to be able to just highlight a cell (or range) and hit Ctrl-B. But I'm not locating a function to do this. I appreciate your help.
Michael Gehrke (1 rep)
Jun 18, 2024, 07:25 PM
Showing page 1 of 20 total questions