Add rows in an excel file with a shell script [closed] - excel

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 days ago.
Improve this question
I'm trying to create a shell script that creates an excel output file and add data in it.
I don't know how to add rows in this excel file. The goal being that the data will be added in separate cells.
I tried many instruction that i found in the web, but none worked for me.
the file after my script would be like below:
Is there an instruction to do this please?
Thanks for your help

This code worked for me:
touch Output.xls
chmod 777 Output.xls
printf "Date\tTotal number\tSuccessful number\tFailed numbe\n" >> Output.xls
printf "2016_05_11\t20\t5\t15\n" >> Output.xls
printf "2016_06_30\t30\t16\t14\n" >> Output.xls
The output file is as below:
enter image description here

Related

Delete the particular line in files using bash script [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 days ago.
Improve this question
Write a program to open the file and delete a specific line from a text file. The line number of the line to be replaced is asked as input. A new file is opened in write mode named output.txt. The input file name should be input.txt and output file name should be output.txt.
someone please help me through it

Adding lines to a linux file using bash script [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed last year.
The community reviewed whether to reopen this question last year and left it closed:
Original close reason(s) were not resolved
Improve this question
I want to add lines '{"index":{"_id":$number_of_id}}' to my file name ss.josn before each json object (which is a line)
cat ss.json
input example:
{"msisdn":"255742005249","subscription_date":"2021-05-26T16:41:40.467Z","optout_date":"2022-01-03T19:12:59.808Z","total_charged_amount":1300}
{"msisdn":"255742009077","subscription_date":"2019-12-31T22:00:00.000Z","optout_date":"2022-01-09T14:08:00.282Z","total_charged_amount":3370}
{"msisdn":"255742009703","subscription_date":"2019-12-31T22:00:00.000Z","optout_date":"2022-01-01T12:34:02.104Z","total_charged_amount":400}
Desired output:
{"index":{"_id":1}}
{"msisdn":"255742005249","subscription_date":"2021-05-26T16:41:40.467Z","optout_date":"2022-01-03T19:12:59.808Z","total_charged_amount":1300}
{"index":{"_id":2}}
{"msisdn":"255742009077","subscription_date":"2019-12-31T22:00:00.000Z","optout_date":"2022-01-09T14:08:00.282Z","total_charged_amount":3370}
{"index":{"_id":3}}
{"msisdn":"255742009703","subscription_date":"2019-12-31T22:00:00.000Z","optout_date":"2022-01-01T12:34:02.104Z","total_charged_amount":400}
If you can ensure that each line is a json struct and you don't have multiline case, a script like this should do the job:
#!/bin/bash
_id=0
while read -r line; do
echo "{"index":{"_id":$_id}}" >> result.json
echo $line >> result.json
_id=$((_id+1))
done < ss.json
Maybe not the most elegant option, but you will have a result.json file with your desired output.

I need a linux script to report all error lines from a log file, and export the results of error lines into a .csv file? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I have log file for checking transactions, and I have error lines, so I need those error lines to be exported to a .csv file? is there any code using linux bash shell script can do this?
suppose your error lines consists ERROR.
then
grep "ERROR" errorfile.txt | tr -s '[:blank:]' ',' >> errorfile.csv
csv conversion is based on blank spaces to each cell.you can replace blank filter with anything

Batch files - names [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I have a code that looks for png files with a specific pattern on the desktop and moves them to another directory.
While going over the files, I want to check if there is the pattern in the name.
This is how I did it:
for %%f in (C:\Users\user\Desktop\*.png) do (
if %%f==Hearthstone Screenshot*.png (
move %%f C:\destination\
)
)
Note: All the needed files start with Hearthstone Screenshot then some numbers.
My main problem is in line 2. I can't make it work.
Depending upon you needs, perhaps this is what you're looking for…
#RoboCopy "%UserProfile%\Desktop" "%UserProfile%\Desktop\HearthStone_Screenshots" "HearthStone Screenshot*.png" /MOV>Nul 2>&1
This should automatically create the holding directory, HearthStone_Screenshots if it doesn't already exist.
Note:I have corrected what I'm assuming to be your very poor spelling issues. If those files and directories should be named using ea instead of ee please re-adjust as necessary.
What's wrong with this:
move C:\Users\user\Desktop\HearthstoneScreanshot*.png C:\Users\user\Desktop\Hearthstonescreanshot\

Error in shell script and how to write to a file [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am writing a shell script that is extracting the data from a command:
I have tried running the script in both the vi and vim editor. But everything in vain.
Please help me out. And how write the output of this in a file.
It may be noted that this is just a starting point so the script will produce multiple files so
I cannot write:
Script_name > filename
I think this question is fine now, the input file is good enough after edit, I can fully understand what you ask for now.
With awk, you need learn to use 2-d array, it will simplify the code.
awk 'BEGIN{print "Instance id Name Owner Cost.centre"}
/TAG/{split($0,a,FS);a[4]=tolower(a[4]);$1=$2=$3=$4="";b[a[3],a[4]]=$0;c[a[3]]}
END{for (i in c) printf "%-18s%-26s%-14s%-20s\n",i,b[i,"name"],b[i,"owner"],b[i,"cost.center"]}' file
Instance id Name Owner Cost.centre
i-e1cfc499 Memcached
i-7f4b9300 Test_LB01_Sachin
i-c4260db8 Rishi_Win_SAML Rishi Pandey
i-fb5ca283 CLIQR-DO NOT TOUCH mataa 1234

Resources