Skip to content
Advertisement

Tag: shell

Getting unexpected newline error while doing awk

I am running the following script in linux command line: I am getting the following error: I believe the quotes and spaces are consistent, but why am i still getting this error? Output of ps -ef | grep “java -Droute=full” Answer The actual problem you’re trying to solve is something like “How to kill the process whose command line contains

Bash offer numberd results for selection to user

my script takes in a site name from the user. Its then allows the user to checkout, edit, and commit changes to the file, via the script. However, some sites have two to six files. So the script lists them as follows You have more than one Cambridge file. Please pick from the following: cambridge1 cambridge2 cambridge3 user enters the

Linux – rename all files by replacing last hyphen with ‘##’

Please anyone. How do I in Linux rename a bunch of files like: abc-def-0001.xxx acb-def-0002.xxx to: abc-def##0001.xxx … I have tried several suggestions from SO like: rename ‘s/(.*)-/$1##/’ *.xxx But didn’t worked as expected in my environment. Answer So I ended up using: for i in *; do mv “$i” “`echo $i | sed “s/(.*)-/1##/”`”; done I think my version

Search and replace file content using shell script

I want to search and replace specific value in a file, here is the content of the file I want to replace DocumentRoot /var/www/html with DocumentRoot /var/www/html/centos I tried the following This is not working, can someone point me to the right direction. Thanks Answer The line you are trying to replace is: It contains double-quotes. The sed command does

tail the last modified file and monitor for new files in bash

I can tail -f the last modified file using ls –sort=time | head -1 | xargs tail -f but I’m looking for something that would continuously run the first part as well, i.e. if a new files is created while the tail command is running it switches to tailing the new file. I thought about using watch command but that

How do I search for a certain piece of text inside of a variable?

I am working on a script which prompts the user for their username. Once entered, the script uses the ‘rwho’ command to get a list of users who are logged into the network. It should crosscheck the text they entered (their username) with the results from the rwho command. If a match is found then it displays a message saying

Advertisement