Skip to content

Tag: bash

Replace white spaces with underscores within a file (bash)

I am currently writing a script that accesses another file using “mapfile” to put it into an array. However, the inputted file contains some white spaces, which the script reads as a new array entry. How do I replace the white spaces with underscores within the body of the file I’m bringing …

How to stop a shell script correctly?

I’ve written a small bash script to start a program every 3 seconds. This script is executed on startup and it saves its PID into a pidfile: The problem is, I can’t terminate the shell script by calling start_gps-read.sh stop. There it should read the pidfile and stop the inital process (from star…

Command works in terminal but not as alias in profile.d

I have a problem regarding an alias file in /etc/profile.d/. This isn’t anything important. I’m just interested why it isn’t working as expected. So basically I have the file 00-alias.sh at the path mentioned above and I wanted to make a shortcut which reads a specific line of a file. So thi…

Spliting large scm files into individual commands

I have a very large scm file that is over 3 million lines long. I am ‘cat’ing it through a telnet port to a virtual server. I need to split the code into its individual lines and feed it into the server. It should send one line and wait a few milliseconds before sending the next line. Ex: … …

How can I delete a specific text in a text file

I have a text file : and I want to delete 192.168.47.1 line I tried but output is : I tried sed ‘s/192.168.47.1//g’ but again output is : I searched on google but but I am not able to find the right one. Answer The problem is that your pattern matches 3 lines in your data. You need to end