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
1
votes
0
answers
450
views
How to make excel interpret Chinese characters in CSV file
I am sending a report from a unix shell script that contains chinese characters. When I open the CSV report in plaintext editor like textmate I can see the chinese characters but when I open CSV report file in Excel I don't see the chinese characters, but some gibberish. How do I "tell" excel that t...
I am sending a report from a unix shell script that contains chinese characters.
When I open the CSV report in plaintext editor like textmate I can see the chinese characters but when I open CSV report file in Excel I don't see the chinese characters, but some gibberish.
How do I "tell" excel that the file contains Chinese charset ?
Here is the code that sends mail and attaches the CSV file.
send_mail() {
v_mailpart="ZZ_/afg6432dfgkl.94531q"
echo "Mail to be sent to $RPT_SEND_TO"
echo "To: $RPT_SEND_TO
Subject: Blah Report as of $report_date_format;
Content-Type: multipart/mixed; boundary=\"$v_mailpart\"
MIME-Version: 1.0
This is a multi-part message in MIME format.
--$v_mailpart
Content-Type: text/html
Content-Disposition: inline
Hi All,
Please find attached, the daily report
Thanks,
Blah Team
NOTE: This is an auto-generated email. Do not reply to it. Please send an email to blah-group@mycompany.com in case of any issues.
--$v_mailpart
Content-Transfer-Encoding:UTF-8;
Content-Type: text/plain;charset=\"UTF-8\";
Content-Disposition: attachment; filename=blah-report.csv
cat $spool_file5
" | /usr/sbin/sendmail -t
}
anu
(362 rep)
Mar 14, 2016, 10:21 PM
• Last activity: Apr 23, 2025, 03:09 PM
4
votes
2
answers
24895
views
view excel files in linux command line without installing any packages
I am connected to a server where I don't have sudo privileges to install packages such as Libreoffice. I only want to view an excel file might be .xlsx or .xls on linux terminal with a command line, is there an easy way to do that?
I am connected to a server where I don't have sudo privileges to install packages such as Libreoffice. I only want to view an excel file might be .xlsx or .xls on linux terminal with a command line, is there an easy way to do that?
kutlus
(375 rep)
Jan 16, 2019, 08:22 PM
• Last activity: Jan 28, 2025, 10:48 AM
0
votes
2
answers
5788
views
Opening .xlsx file in linux terminal
I work in a cluster. I would like to ask if it is possible to open .xlsx files in text editors like nano or vim. Is there any possible way if I have not Microsoft Excel (or any relevant application in my PC) to read the file. If it helps my laptop is Windows and I connect via Mobaxterm to the cluste...
I work in a cluster. I would like to ask if it is possible to open .xlsx files in text editors like nano or vim.
Is there any possible way if I have not Microsoft Excel (or any relevant application in my PC) to read the file.
If it helps my laptop is Windows and I connect via Mobaxterm to the cluster.
$ lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: Rocky
Description: Rocky Linux release 9.4 (Blue Onyx)
Release: 9.4
Codename: BlueOnyx
Dimitris Tsiaousidis
(9 rep)
Sep 13, 2024, 09:07 AM
• Last activity: Oct 7, 2024, 06:46 AM
0
votes
2
answers
108
views
CSV output for Number data
Below is a tab delimited sample. When I open this file with notepad it looks good for numbers. But if I open it with excel, numbers do not look correct. They look +11 at the end but inside if I double click data is correct. I want to see the actual values instead of +11 at the end, if I use excel sp...
Below is a tab delimited sample. When I open this file with notepad it looks good for numbers. But if I open it with excel, numbers do not look correct. They look +11 at the end but inside if I double click data is correct.
I want to see the actual values instead of +11 at the end, if I use excel spreadsheet.
I don't want to manually change format of the cells to text and see the value (or) change format to numbers and see the data. That would be manual approach. I want this to be automated. When a file is generated as file.csv from Informatica powercenter and opened in Excel the numbers should look correct without having to double click the cells.
Can this be done with Unix script? I would be happy with xlsx format if it is not possible with csv.
Name Number address pin
John 23435435 usa 235
Jacob 2342342 india 234
Jack 35345345 uk 345
Jet 3234234 canada 323
jub 234234 australia 366
codecheck123
(1 rep)
Oct 18, 2023, 08:20 PM
• Last activity: May 11, 2024, 07:39 AM
8
votes
5
answers
1839
views
How to round to 2 decimals in bash like MS Excel does?
I spent hours in searching how to round "floating numbers" in BASH but couldn't find any correct! solution :( If I put these numbers to Excel, then I will receive the correct results after rounding to 2 decimals: 3.314 -> 3.31 3.315 -> 3.32 8.124 -> 8.12 8.125 -> 8.13 How to have the exact results i...
I spent hours in searching how to round "floating numbers" in BASH but couldn't find any correct! solution :( If I put these numbers to Excel, then I will receive the correct results after rounding to 2 decimals:
3.314 -> 3.31
3.315 -> 3.32
8.124 -> 8.12
8.125 -> 8.13
How to have the exact results in BASH? I tried with
printf
and awk
but don't have the same result
prompt> printf '%.*f\n' 2 8.125
8.12
prompt> echo '8.125' | awk '{printf("%.2f\n", $1)}'
8.12
user3719454
(202 rep)
Oct 24, 2023, 11:22 AM
• Last activity: Oct 28, 2023, 11:46 AM
0
votes
0
answers
1649
views
how to compare text file datas with excel sheet values
For Example : in my `username.txt` file ravi peri perl phython in my .xls file i have two columns named as user name and email username email ravi ravi@gmail.com peri peri@gmail.com I want to produce the output in list order like excel view or normal list view .Please help me to solve this issue .
For Example :
in my
username.txt
file
ravi
peri
perl
phython
in my .xls file i have two columns named as user name and email
username email
ravi ravi@gmail.com
peri peri@gmail.com
I want to produce the output in list order like excel view or normal list view .Please help me to solve this issue .
Ravi
(39 rep)
Aug 8, 2017, 06:15 AM
• Last activity: Aug 13, 2022, 12:03 PM
0
votes
1
answers
2892
views
How to find spreadsheet files that contain a word
Something like the answer here: https://superuser.com/questions/313187/search-text-in-multiple-excel-files but on linux mint.. xlsx files within a folder that contain the string
Something like the answer here:
https://superuser.com/questions/313187/search-text-in-multiple-excel-files
but on linux mint..
xlsx files within a folder that contain the string
malaki106
(3 rep)
Nov 7, 2019, 06:28 PM
• Last activity: Oct 20, 2021, 06:04 PM
-3
votes
1
answers
50
views
How to make a test data for full length of definition?
How to make a test data for full length of definition ? ======================================================= Thanks for your replies to my threads. I am looking to make a test data to satisfy the full length of field definition. For instance, with this data structure: Name varchar (10) Business N...
How to make a test data for full length of definition ?
=======================================================
Thanks for your replies to my threads.
I am looking to make a test data to satisfy the full length of field definition.
For instance, with this data structure:
Name varchar (10)
Business Name varchar (15)
Address Varchar (20)
there are many more fields around 70-80 after above sample
Test file to be with '|' delimiter
xxxxxxxxxx|uuuuuuuuuuuuuuu|pppppppppppppppppppp
The above is a sample. The fields can be filled with fake characters
If Numeric like number (9,2) with digits
If character like varchar like varchar(20) mix of alphabets & digits
some files use ASCII '\031' as delimiter.
I tried to do this with excel, unix tools, but I couldn't figure it out. I need forum's guidance.
The awk code given below, how to add different record structure & ASCII '\031' as delimiter?
Am I able to do the above ?
How do I do that?
Thanks for your guidance.
UPDATE:
Thanks for sharing the code. I did test the posted code. It makes the desired output.
If I want to improve this code to make random(FAKE) characters instead of 'x', 'p', 'u', what are linux commands do this? The desired output look like.
12x 15u 8z 6y 12q
xxxxxxxxxxxx|uuuuuuuuuuuuuuuu|zzzzzzzz|yyyyy|qqqqqqqqqqqq
AbXyTruxMgYu|ioPkLmByKuYnBgFr|DcMdWeqo|pnBBv|xmvbghYYueIr
I need to make some digits as well like 923456.4532 etc based on data type
How do we use
openssl rand
gpw
in this script?
We are using the '|' field separator in this script. If I want to change this to ASCII \031 (\031 ^Y EM end of medium (?!)), will changing Sep = "^Y"; work ?
Thanks for sharing.
user2647763 - RIMD
(1 rep)
Mar 31, 2021, 01:39 AM
• Last activity: Apr 3, 2021, 05:50 PM
-2
votes
1
answers
330
views
Format data into excel
I have a large number of data in below format as a txt file. As you can see, each line has Title and then path. What is need here is, i need the data to be present next to each other in an excel - something like Title: Path: Can someone please assist in resolve this? **Current result** ```sh Title:P...
I have a large number of data in below format as a txt file. As you can see, each line has Title and then path. What is need here is, i need the data to be present next to each other in an excel - something like Title: Path:
Can someone please assist in resolve this?
**Current result**
Title:Projects and Ideas
Path:/content/en_us/
Title:buying-guide
Path:/content/en_us/buying-guide
Title:Choose Exterior Paint Colors
Path:/content/en_us/buying-guide/choose-exterior-paint-colors
Title:Water Softener Buying Guide
Path:/content/en_us/buying-guide/water-softener-buying-guide
Title:Presentation Page
Path:/content/en_us/buying-guide/presentation-page
**Expected Result**
Title:Projects and Ideas Path:/content/en_us/
Title:buying-guide Path:/content/en_us/buying-guide
Title:Choose Exterior Paint Colors Path:/content/en_us/buyingguide/choose
Title:Water Softener Buying Guide Path:/content/en_us/buying-guide/water
Title:Presentation Page Path:/content/en_us/buying-guide/presentation-page
Surendar
(35 rep)
Feb 1, 2021, 07:26 AM
• Last activity: Feb 1, 2021, 10:59 AM
1
votes
3
answers
6001
views
Convert shell results into Excel File in columns
I am running a shell script that gives the below result, and I want to store the result in Excel in different columns (HOST, Status, Expires, Days). How can I convert into Excel? ```none Host Status Expires Days ----------------------------------------------- ------------ ------------ ---- FILE:cert...
I am running a shell script that gives the below result, and I want to store the result in Excel in different columns (HOST, Status, Expires, Days). How can I convert into Excel?
Host Status Expires Days
----------------------------------------------- ------------ ------------ ----
FILE:certs/dnscert.crt Valid Aug 4, 2021 359
pavan
(13 rep)
Aug 10, 2020, 12:45 AM
• Last activity: Aug 10, 2020, 08:00 AM
0
votes
0
answers
1683
views
Recover overwritten CSV files with multiple worksheets
- I have a CSV file with one worksheet. - After editing with Libre Office, I saved it and opened it with Libre Office again. - I created a new sheet in the Libre Office. - I saved it and opened it with Sublime Text. - I couldn't see the data from both sheets. Still, I edited in Sublime Text and save...
- I have a CSV file with one worksheet.
- After editing with Libre Office, I saved it and opened it with Libre Office again.
- I created a new sheet in the Libre Office.
- I saved it and opened it with Sublime Text.
- I couldn't see the data from both sheets. Still, I edited in Sublime Text and saved the .csv file.
- I reopened the workbook with Libre Office again.
All my previous worksheets are lost. Only the last worksheet is remaining.
I have been working on the other sheets for almost the past 10 days. All the work seems like it's gone. Ultimate frustration :( Is there a way to restore the lost data?
Sai Nikhil
(101 rep)
May 3, 2020, 01:02 AM
0
votes
1
answers
7719
views
Is it possible to run excel macros in linux?
Ideally this is a python-specific question but my findings so far are negative. So I would like to generalize it to seek a way to run Excel VBA macros in linux environment. What are the actual limitations if it is impossible?
Ideally this is a python-specific question but my findings so far are negative. So I would like to generalize it to seek a way to run Excel VBA macros in linux environment.
What are the actual limitations if it is impossible?
henrywongkk
(119 rep)
Oct 23, 2019, 08:38 AM
• Last activity: Oct 23, 2019, 08:50 AM
1
votes
2
answers
1001
views
Convert Excel file to PDF using Perl CGI
I'm trying to convert an xlsx file to pdf using Perl CGI (Mason). Since I did not find a way to convert a file using pure perl, I'm using `soffice` to perform the job. This works fine until I do it through browser. The code responsible for conversion is pretty simple: my @cmd = ( "soffice", "--headl...
I'm trying to convert an xlsx file to pdf using Perl CGI (Mason).
Since I did not find a way to convert a file using pure perl, I'm using
soffice
to perform the job.
This works fine until I do it through browser.
The code responsible for conversion is pretty simple:
my @cmd = ( "soffice", "--headless", "--convert-to", "pdf", $filename );
system(@cmd);
This works fine on command line, when ran by a regular user, but running it as Apache user (Mason on Apache), throws an error:
(process:14954): dconf-CRITICAL **: 14:28:42.846: unable to create directory '/usr/share/httpd/.cache/dconf': Permission denied. dconf will not work properly.
Can anyone point me to right direction?
Is there a way to convert xlsx to pdf using just perl, not system commands?
# Edit
To pass dconf
error, I've manually created the directory tree it's complaining about and chowned it to apache user, however, there's next error:
[Java framework] Error in function createSettingsDocument (elements.cxx).
javaldx failed!
Warning: failed to read path from javaldx
Same goes if I try unoconv
:
Error: Unable to connect or start own listener. Aborting.
# Solution
Starting unoconv --listener
manually before the operation, does the trick and solves my issue. PDF files are being created.
Bart
(2314 rep)
Jul 12, 2019, 02:30 PM
• Last activity: Jul 12, 2019, 03:11 PM
1
votes
1
answers
2207
views
convert an excel file to pipe delimiter file in Linux using script
Need to convert an excel file to pipe delimiter file in Linux using shell script. pls help I'm new to shell script. I saw a post to convert comma to pipe using the below code... awk '{for(i=1; i<=NF; i+=2) gsub(",","|",$i)}1' FS=\" OFS= file how to change this command for excel file to pipe?
Need to convert an excel file to pipe delimiter file in Linux using shell script. pls help
I'm new to shell script.
I saw a post to convert comma to pipe using the below code...
awk '{for(i=1; i<=NF; i+=2) gsub(",","|",$i)}1' FS=\" OFS= file
how to change this command for excel file to pipe?
user3844609
(11 rep)
Jul 10, 2019, 05:48 AM
• Last activity: Jul 12, 2019, 08:38 AM
4
votes
1
answers
247
views
How can i add Write protected access to an excel in linux
I have a ETL job that creates the excel file and puts into one of the unix directory. I have an unix "mailx -s" command to send that excel as an attachemnt. I am looking for a way to extend my program or script to make the Excel file write protected before sending it in mail. The program/script shou...
I have a ETL job that creates the excel file and puts into one of the unix directory.
I have an unix "mailx -s" command to send that excel as an attachemnt.
I am looking for a way to extend my program or script to make the Excel file write protected before sending it in mail. The program/script should run on Linux/Unix ?
Is there any way.. Please suggest.
Arya
(336 rep)
Jul 8, 2019, 03:51 PM
• Last activity: Jul 10, 2019, 01:30 AM
2
votes
1
answers
1556
views
How to convert sc spreadsheet to Excel?
> The spreadsheet calculator sc is based on rectangular tables much like a financial spreadsheet. When invoked it presents you with a table organized as rows and columns of cells. If invoked without a file argument, the table is initially empty. Otherwise file is read in (see the Get command below)....
> The spreadsheet calculator sc is based on rectangular tables much like
a financial spreadsheet. When invoked it presents you with a table
organized as rows and columns of cells. If invoked without a file
argument, the table is initially empty. Otherwise file is read in (see
the Get command below). Each cell may have associated with it a
numeric value, a label string, and/or an expression (formula) which
evaluates to a numeric value or label string, often based on other cell
values.
How to convert sc spreadsheet to Excel format?
zotherstupidguy
(287 rep)
Feb 5, 2017, 01:06 PM
• Last activity: Jun 7, 2019, 05:01 AM
1
votes
2
answers
5997
views
How to convert a space-separated file into an Excel file in Linux?
I have a file which looks like this: ID avedebv debv2019 ebv2018 gebv2018 number avecvlean 7063993 1.06109 0.5325 0.7420 1.5084 206 66.5962 7076247 1.67947 2.1066 2.8630 3.0629 460 67.6856 7076881 -0.236859 -2.6794 0.8820 1.9994 282 66.1557 7126254 -0.409945 -2.2293 0.5860 1.2695 133 66.0323 7178892...
I have a file which looks like this:
ID avedebv debv2019 ebv2018 gebv2018 number avecvlean
7063993 1.06109 0.5325 0.7420 1.5084 206 66.5962
7076247 1.67947 2.1066 2.8630 3.0629 460 67.6856
7076881 -0.236859 -2.6794 0.8820 1.9994 282 66.1557
7126254 -0.409945 -2.2293 0.5860 1.2695 133 66.0323
7178892 0.464492 -0.0859 1.2640 1.3655 327 66.3985
7179256 1.33735 2.2111 1.4730 1.0873 48 67.9671
7247048 0.875797 0.8434 1.5680 2.3221 86 67.8639
7247721 2.44818 3.8560 2.2590 3.7478 306 69.2416
7271572 2.54853 4.1963 2.5310 2.4604 268 68.9649
7271958 1.48163 2.1094 2.6480 2.4154 396 67.8631
7310883 2.07762 2.6693 0.5610 0.8019 164 69.8769
7339810 1.93014 2.7640 2.4130 2.0771 112 70.453
7362729 1.79878 2.5744 1.5900 2.6763 247 69.8597
7383443 1.20869 1.0631 0.6140 0.7587 229 69.4386
7384385 1.95598 1.2635 3.1930 2.1413 32 71.9848
7385021 3.01675 3.7090 1.3690 1.4910 22 71.2533
7385509 0.686986 -0.1679 0.1500 0.2087 81 69.8795
7392631 2.07126 4.0996 0.8400 1.6370 103 70.6173
I want to change its format into an Excel file, so I can work on this data in Excel. How can I convert it with Linux?
zara
(1333 rep)
May 24, 2019, 03:15 PM
• Last activity: May 28, 2019, 05:40 PM
1
votes
0
answers
89
views
Can I manipulate .xls workbooks in linux (tcsh)
I have 2 Excel Workbooks, A and B. Workbook A.xls has 2 worksheets, Sheet1 and Sheet2. Workbook B.xls also has Sheet1 and Sheet2. Without opening the workbooks, I would like to delete Sheet2 in A.xls, and replace it with Sheet2 from B.xls. It is something that I need to do quite a lot, hence the nee...
I have 2 Excel Workbooks, A and B.
Workbook A.xls has 2 worksheets, Sheet1 and Sheet2.
Workbook B.xls also has Sheet1 and Sheet2.
Without opening the workbooks, I would like to delete Sheet2 in A.xls, and replace it with Sheet2 from B.xls. It is something that I need to do quite a lot, hence the need to cut out the opening of the workbooks!
ZakS
(315 rep)
Apr 9, 2019, 12:45 PM
• Last activity: Apr 10, 2019, 10:25 PM
0
votes
1
answers
1130
views
Perl script to format .xls file in Linux
All I have is a linux command (I don't know what's behind the command, the script or what formats the command output), so what I can do is to pull the data [which is in table form with invisible column lines], out from linux, and send it out to people for reviewing purpose. When I run the command, t...
All I have is a linux command (I don't know what's behind the command, the script or what formats the command output), so what I can do is to pull the data [which is in table form with invisible column lines], out from linux, and send it out to people for reviewing purpose.
When I run the command, the generated output are nicely formatted in aligned columns on my console screen, even when I put it into diff types of file extension: .txt / .csv / .xls (they are all nice in linux terminal)
> thatCommand | mail -s 'Statistics' my@email.com
Above: print output as message body in the email
Below: redirect output to a file and send it out as attachment in email
> thatCommand > stat.xls
> uuencode stat.xls table.xls | \mail -s "Statistics" my@email.com
Then, I have this problem,
after executing the first command line, the table in my message body is shown like below
> Student Name ID SubjectA(%) SubjectB(%)
> Aaron Frank 7892 89 100
> Benjamin Ayres 8892 78 90
How I would like it, to be arranged according to columns:
Student Name ID SubjectA(%) SubjectB(%)
Aaron Frank 7892 89 100
Benjamin Ayres 8892 78 90
So I tried 2nd command lines with attachment instead. After receiving those different types of file extension attachment in mail, save and open them in windows. (in my PC, csv and xls are by default open by excel, txt open using notepad)
The output supposed to be in different columns (it's a table in linux before I exported it),
but instead all the data is in the first column, looking messy in excel application. [looking messy in notepad too]
The below image is my endgoal, data values in different columns (well aligned)
how it looked like now, the data are all in columnA only
Is perl script able to help? So that I could get the nicely formatted output when received the attachment? I wouldn't mind because I still have to add some info at the end of the excel file in linux. (even though I have yet to figured out how to do that), but for now my main concern is on how to format it :)
This is the [link](https://unix.stackexchange.com/questions/355271/run-multiple-commands-and-put-into-different-excel-worksheets) question what would be further done.


Santa
(17 rep)
Mar 20, 2017, 02:22 AM
• Last activity: Jan 13, 2019, 10:17 PM
Showing page 1 of 20 total questions