I have a text file (file.txt) having content something like: It contains the process and respective PID. Using shell script, I want to append a string (running/not running) to that lines in this file, according to the PID. For example, in the above file, for line containing PID 3696, I want to append a string “running” at the end, so
Tag: shell
Bash terminal and color output [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 10 years ago. Improve this question I have a shell with colors enabled: somefile contains escape characters for coloring. Now I want to output somefile to the terminal with its coloring. I tried: But
Is there a way to write to a Google docs spreadsheet from the Linux shell?
I have a cron job that exports some data to CSV every day. Is it possible to write this data directly to a Google doc (spreadsheet) from the Linux shell (Ubuntu)? Answer For that you have the Google Documents List API Example code at Write to a Google Spreadsheet from a Python script
Bash while read loop extremely slow compared to cat, why?
A simple test script here: When I do cat my450klinefile.txt | myscript the CPU locks up at 100% and it can process about 1000 lines a second. About 5 minutes to process what cat my450klinefile.txt >/dev/null does in half a second. Is there a more efficient way to do essentially this. I just need to read a line from stdin,
Save argument ${1} passed to a shell script in a variable within shell script
I want to save ${1} argument passed to my script (${1} is a file path) into a string variable within the same shell script, and then echo the path using echo variable and not echo ${1}. Answer Simply try doing this :
Convert a time span in seconds to formatted time in shell
I have a variable of $i which is seconds in a shell script, and I am trying to convert it to 24 HOUR HH:MM:SS. Is this possible in shell? Answer Here’s a fun hacky way to do exactly what you are looking for =) Explanation: The date utility allows you to specify a time, from string, in seconds since 1970-01-01
wget: Unsupported scheme on non-http URL
I have the following line in my shell script: When I tried to run the script it give me the following error: Does it mean wget supports http and ftp ONLY? Answer man wget shows: It supports HTTP, HTTPS, and FTP protocols, as well as retrieval through HTTP proxies. Try curl, it supports file URLs. Also note you probably want
Bash command to check if the variable name is valid
and so on the variable name can have only letters , numbers (but not on the beginning),.. and like all the rules for java… Is there any function that I can use ? I do not want to reinvent the wheel… Answer Match the variable name against a regex, like this:
Shell script for remote SSH
I’m new to shell scripts, and I have centos running. I want to write a shell script that ssh a remote machine and execute a bunch of commands. The problem I’m facing is how to provide the username, the password, the remote machine address, and the private access key to a command that shall connect the remote machine. I’ve Google’d
Interacting with a .db file from Linux shell
I recently installed minidlna, a lightweight UPnP server, on my Raspberry Pi. Since this lacks the web interface of other programs such as Mediatomb, I thought it could be an interesting project for me to write one. I believe minidlna stores library information in a single file named “files.db”. EDIT: I was advised to check the output of file files.db