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

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

Related

Add rows in an excel file with a shell 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 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

unix -https url download content and the same move another location [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 9 months ago.
Improve this question
i have URL https://my.waves.com/:r:/documents%20-/csv%20upload that loaded the screen then show edc_data.csv
above file edc_data.csv file move unix Location(/equ/str/loaded)
can you please how to write shellscripts
Assuming your URL https://my.waves.com/:r:/documents%20-/csv%20upload is correct and links to a CSV file, you can use this script:
#!/bin/sh
curl -L 'https://my.waves.com/:r:/documents%20-/csv%20upload' > /equ/str/loaded/edc_data.csv
exit 0
This will download the file edc_data.csv and put it directly in /equ/str/loaded/.

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

Convert xlsx to text CSV via command line only on Linux [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
Simple question:
Is it currently possible to invoke LibreOffice from a command line to open a *.xlsx and convert/save it as a *.csv?
Alternatively, if this is not possible what is the current best method for doing this via command line (needs to be invokable via script)?
Thanks,
Here is the command:
localc --headless --convert-to csv:"Text - txt - csv (StarCalc)" *.xlsx
The above will save all converted files in current directory(directory from where you'll run the command). All converted files will have their filename extensions changed to csv.
Alternative, method is the use of unoconv which i've not used.

Resources