[Solved] bash : run sed -i multiple times

Running sed -i on the same file multiple times is a horrible antipattern. Just do all the substitutions in the same sed script. You need to escape many more metacharacters than you currently do. See Escape a string for a sed replace pattern for some details. Probably that’s the reason many of your substitutions don’t … Read more

[Solved] Exporting SVG image to points using bash

the “array” variable is not well initialized. To capture the output of the commands you are executing, they should be sourrounded by $() With this change, the script works for me: array=$(grep “\bd=” $file | sed -r “s/(-)?[0-9]+(\.)?(-)?([0-9]*)?,(-)?[0-9]+(\.)?(-)?([0-9]*)?/{ & },\n/g” | grep -o “{.*},”) 0 solved Exporting SVG image to points using bash

[Solved] How to show the Linux command line on 1 row? [closed]

You need edit the file .bash_profile, Open the terminal Run the command to edit: nano .bash_profile Insert this line: export PS1=”[\e[0;31m]\u[\e[0;36m]@[\e[1;36m]\h[\e[1;34m]:[\e[1;33m]\w[\e[0;31m]$ [\e[0;37m]” Ctrl+X to save, close and open again the temrinal You will get a user@host:~/working/dir $ 2 solved How to show the Linux command line on 1 row? [closed]

[Solved] Shell scripting to find the delimiter

To count the number of columns with awk you can use the NF variable: $ cat file ABC|12345|EAR PQRST|123|TWOEYES ssdf|fdas,sdfsf $ awk -F\| ‘NF!=3’ file ssdf|fdas,sdfsf However, this does not seem to cover all the possible ways the data could be corrupted based on the various revisions of the question and the comments. A better … Read more

[Solved] Read a file using argv

You can run the program as: IFS=$’\n’ ./sort.exe $(cat file.txt) Each line of the file will then be an argument to the program (setting IFS to just newline prevents spaces in the file from being argument delimiters). Then the program can loop over argv (except for argv[0], which contains the program name) to get all … Read more

[Solved] filenames to mysql database [closed]

Use PHP glob() function to get all files from a folder $files = glob(directory_path.”/*”); // get all files in a folder // Loop through array of fetched files and insert into database. foreach ($files as $file) { $filename = basename($file); // WRITE YOU MySQL code here that inserts filenames into DB } MySQL Insert 0 … Read more

[Solved] in Bash,How to check user login [closed]

This will count multiple logins of a single user as multiple matches i.e if you ssh into a machine 3 times with the same account this will show 3 users echo $(date) $(who | awk ‘{print $1}’ | wc -l) users >> log.txt To treat multiple logins from one username as one match this is … Read more

[Solved] Bash – back tick invocation blocks for ever

if the call to callee.sh is hanging with parameters, try executing it outside the script with parameters and check if it is hanging there as well… Anyways, the best way of saving output (and printing it out afterwards): result=”$(./callee.sh param1 param2 param2)” echo “${result}” <— this should show the line breaks 1 solved Bash – … Read more