Please I have a text file separated by spaces. I would like to output it to columns separated by ; example Input I use this code My output Output desired. Appreciate your help. Answer $1=$1 is a trick to rebuild $0 with the new separator OFS=’;’.
Tag: bash
Not able to change DOCTYPE line of a xml file in bash
I have a xml file with name alphabet.xml like below : – Now I want to replace <!DOCTYPE models SYSTEM “mp.dtd”> String of alphabet.xml with <!DOCTYPE models SYSTEM “/opt/nms_cif_mp/dat/mp.dtd”> code I am using is in below . But with this code replacement of the above …
parsing complex string using shell script
I’m trying the whole day to find a good way for parsing some strings with a shell script. the strings are used as calling parameter for some applications. they looks like: I’m only allowed to use shell-script. I tried to use some sed and cut commands but nothing works fine. My tries are like: that…
Do here-strings undergo word-splitting?
Quoting Bash Reference Manual and man bash (version 4.3): [n]<<< word The word undergoes brace expansion, tilde expansion, parameter and variable expansion, command substitution, arithmetic expansion, and quote removal. Pathname expansion and word splitting are not performed. The word should not unde…
Bug while checking for symbols inside of a string?
I’m creating a small calculator script and I’ve got stumbled on a strange bug. Everything seems to work but not when I input anything starting with (. When I do that if gives false and the code inside of else executes. I’ve tried a lot of ways rewriting how should “$input” =~ [-,…
shell script to use cl1p.net online clipboard in linux – Error (23) Failed writing body [closed]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack …
How to store command arguments which contain double quotes in an array?
I have a Bash script which generates, stores and modifies values in an array. These values are later used as arguments for a command. For a MCVE I thought of an arbitrary command bash -c ‘echo 0=”$0″ ; echo 1=”$1″‘ which explains my problem. I will call my command with two …
Recursively check the difference between files in shell
I am trying to recursively check the difference between files in 2 separate directories in shell. NOTE :- both directories are identical only the root name is different In the diagram shown above I want to “diff ROOT_A/A.md5 ROOT_B/A.md5” recursively in my script file for all files in the root dir…
delete all folders and files within a linux directory except one folder and all contents inside that folder
I have a directory structure as :- I want to keep the public folder and all its contents (further folders and files within it) but want to delete everything else under the directory /usr/testing/member/. But that also means member folder is not deleted. Is there any shell script or command that can be used to…
Creating files from a Python script within a shell script within a shell script
I’m trying to run a Python script from a shell script within a shell script, but I’m running into some problems. Imagine my root shell script looks like this: and my test2.sh: The python file is in the same directory as test2.sh but test2.sh’s working directory seems to be the root’s s…