I have a file containing more than 14000 records. What I want to do is to process this file line by line and replace a String by anodher string returned by grep command. For example: Line : My grep command to get Class.java string is (Class.java is juste an example): I must, for each line, replace the TAG string by
Tag: shell
bash hiding default stderr code and replacing it with my own
When I use ping foo.com I either get a response or ping: unknown host foo.com I am using this script to show custom responses the problem with the above is that, if site is found I get site found response, but if not instead of the error message, I get the default ping: unknown host foo.com UPDATED. . Answer if
sed removes one string in one file
I’m trying to remove one string in one file by using: But I’ve got the following error: What is it missing and why? Thanks! Answer /example/ is an address which tells sed where to run commands – on a line containing the string example. You didn’t specify any commands. This is a commnand that replaces the string example with an
Dynamically-created ‘zip’ command not excluding directories properly
I’m the author of a utilty that makes compressing projects using zip a bit easier, especially when you have to compress regularly, such as for updating projects submitted to an application store (like Chrome’s Web Store). I’m attempting to make quite a few improvements, but have run into an issue, described below. A Quick Overview My utility’s command format is
Shell Script file access
I have written a shell script on my mac. Following code: The problem is that the program wlalink gives me an error message: LOAD_FILES: Could not open file “temp.prj”. It seems that there are problems with some rights. The script is creating a file and there is the right content in the file. Same with running sudo. Any ideas? Answer
struggling with a shell script in linux
I am trying to create a script that takes two arguments, source folder and target folder. I am trying to show an error message if the source directory is not found and exit the program. If target directory is not found, I would like it to create that directory. Then I would like to copy all the contents from the
How can I execute a shell script on linux directly from a URL if it needs to change environment variables?
Goals: One-liner script execution Changes environment variables in the caller Is this possible? I know you can do something like curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.29.0/install.sh | bash, but this doesn’t allow changing environment variables in the calling environment. Answer You can use process substitution together with the . (source) command: This would import all variable, alias and function definitions from env.sh into
Running a script in terminal using Linux
Im trying to run this script in the terminal but its not working and says permission denied. scriptEmail is filename. scriptEmail is written as follows: My read write permission Answer As for permissions: Check that your shebang is at the very top of your file, and that it starts exactly with #!; # ! will not work. Check that your
How to execute sh command set in shell variable?
I have this linux command: candump -l -e -x -s 0 -n 10 any,0~0,#FFFFFFFF 2> /dev/null > /tmp/can.log & It works correctly when I run it directly in shell. I want to add it in my script with this method: When I execute my script I get this error: SIOCGIFINDEX: No such device I have tested these script and it
Shebang option ‘ #!/bin/csh -f ‘
What does the Shebang option -f do? How do I find, or man, detailed explanations on all Shebang options? Answer There aren’t any “shebang options”. Any options there are options to the binary in the shebang. So that’s a csh option. Specifically (from the man page): -f The shell will start faster, because it will neither search for nor execute