Apologies ahead of time if this is stated wrongly as I have searched but could not find how to sed + echo while using while loop to read a file. I have a before.txt file that looks like this: and I need it to look like this: This is what I have so far … But it fails How do
Tag: bash
Expect: How to iterate over files in a directory?
The following is a bash script which iterate over .csv files within a directory. The question is, I now have an expect script #!/usr/bin/expect where I want to use the same for loop. How could I achieve that? Answer You would write: Expect is an extension of Tcl. In addition to the expect man page, a link to …
How to get current foldername and remove characters from the name in bash
I’m trying to write a single command in my makefile to get the current folder and remove all “.” from the name. I can get the current folder with $${PWD##*/} and I can remove the “.”s with $${PWD//.} but I can’t figure out how to combine these two into one. The reason I nee…
Get variable name while iterating over array in bash
What I have is an array with some variables. I can iterate to get the values of those vars but what I need is actually their names (values will be used elsewhere). Going with var[i] won’t work cause I will have different names. I guess I could workaround this by creating another array with the names …
Losing stdout data in python
I’m trying to make a python script which is going run a bash script on a remote machine via ssh and then parse its output. The bash script outputs lot of data (like 5 megabytes of text / 50k lines) in stdout and here is a problem – I’m getting all the data only in ~10% cases. In other 90%
Awk script to sum multiple column if value in column1 is duplicate
Need your help to resolve the below query. I want to sum up the values for column3,column5,column6, column7,column9,column10 if value in column1 is duplicate. Also need to make duplicate rows as single row in output file and also need to put the value of column1 in column 8 in output file input file output fi…
decimal value is not printing in bash?
I want to evaluate the expression and display the output correct to 3 decimal places i tried with below code but it is not working help me how to do that in bash. Answer With bc: Output: 17.928
Remove first 3 characters and last 1 character from all mp3 files in all subdirectory
In base directory i have folders like this: so in each of them i have files like so i want to remove first 3 characters and last 1 character so files will look like this i tried this also this is not working in subdirectories it is just if files are in base directory Answer You may use this while
bash printf not working – decimals [closed]
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 4 y…
Symbolic link difference between cp -sr and ln -s [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 …