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…
Tag: bash
List and change directory and run command in Shell
I am coming back to shell after almost 6 years or so. I have a directory structure let’s say, MainDirectory –> subDirectory1/some.xml –> subDirectory2/some.xml … … –> subDirectoryN/…
Copy fails in bash script even when I use `/bin/cp` and chmod 777 on the file
I wrote a bash program to setup new Debian install’s…. but I can’t figure this problem/error out…… I can’t get it to copy a .bashrc file to a new users /home directory even with 777 permissions. Here are the declarations and setting of the variables: Here are the files the …
How to merge two rows in a same row from a text file in linux shell script
From Nagios I downloaded its html file by using wget command and then I converted that htmlfile to Textfile by using following code: then I cut the first 10 lines becoz I dont want that text and I got below textfile output I have to merge two rows into single row not for all lines only for particular output f…
Trouble writing bash sed command – regex match
I have a file full of garbage collection information that is irregular, some lines have extra information that I want to initially remove so I can then process the the file as a whole. Unfortunately the line has quite a few special characters and I am struggling with a sed command that manages to match the bi…
multi pattern in sed -n
I know there are quite a few questions asked on this topic. But I need help in a case basis.When i try to put more than 3 pattern in the option, i will get the error like that… i only want to print the words in the brackets.. here is the sed command and the output… thanks… sample output Answ…
writing a shell in C my program is not able to exit()
I am writing a program to implement a simple shell in C but when I execute the program at the end when I type exit it does not exit. I am executing in on cygwin hence a.exe is generated. execution of program Here you can see in the above output the program is not able to exit when I am
How to efficiently loop through the lines of a file in Bash?
I have a file example.txt with about 3000 lines with a string in each line. A small file example would be: I want to check all repeated lines in this file and output them. The desired output would be: I made a script checkRepetions.sh: However this script is very slow, it takes more than 10 minutes to run. In…
Search and Replace ( multiple lines )
Hello StackOverflow Community! I’m working on a bash script to change in Dynamic text file, I want to replace multiple lines with one line. Ex: This example, I want to replace THIS With KKKKK Before script After script I found a script to replace using ( sed ) but it doesn’t replace multiple lines…
optimizing awk command for large file
I have these functions to process a 2GB text file. I’m splitting it into 6 parts for simultaneous processing but it is still taking 4+ hours. What else can I try make the script faster? A bit of details: I feed my input csv into a while loop to be read line by line. I grabbed the values from the