I need help extracting blocks of information from a single text file into new files or some form where I can manipulate the data from each block. Example: I need to be able to display and/or manipulate the variables (which I can do if I can isolate the right one). I don’t mind writing each one of these …
Tag: bash
Using a compiled Python shell in Linux
Is it possible to use a “more complex” shell than just a single command shell? We have written a python shell that is a command loop, and it works fine in /etc/passwd like this: Of course the Python file has the shebang line for /usr/bin/python in it. However, we’d like to compile the Python…
JSON list (not object) to Bash array?
I’ve got a JSON list (the value of a key-value pair containing a list of items): [ “john”, “boris”, “joe”, “frank” ] How would I convert this to a bash array, so I can iterate over them? Answer Easy Case: Newline-Free Strings The simple approach is to use …
Bash: Want to move certain amount of files, that contains spaces to a different directory
So I’m quite new with bash and Stack Overflow in general, so forgive me if I may be missing something. I’ve been trying to create a script that moves a certain amount of files (ex: 3 files), that may contain spaces (like “hello world.txt”), to another directory. I’ve tried a few …
Combining ionice and nice in Linux, and transitive priorities
I want to load use both ionice (I/O priority) and nice (process priority) to start-up a program. I see variations of this line all over the internet: (or) Everyone lists it without any elaboration. My question is… how does ionice (the first program) setting the priorities of nice (the second program), a…
compare two comma separated strings and list the common values
How many I compare the two comma separated list (master and input) and list the common values among them (result) while preserving the order of elements in master list. For example: case1: case 2: case 3: This is what I tried: Answer Here is one awk-oneliner solution: Test with your 3 cases: Case 1 Case 2 Cas…
bash: Create a ncurses dialog radiolist from a dynamic file and output selection to variable
I am working on building a ncurses/dialog driven interactive shell script to Clonezilla to simplify the creation and restoration of images passed with very specific settings that we use each time. Part of the script asks the user to select an image for restoration and I have hit a wall. I want to use a dialog…
Sed/awk: Aligning words in a file
I have a file with the following structure: I want to add another item to the file, using sed or awk: etc. So my next item looks like this: The column values is jagged. How do I align my values to the left like for previous items? I can see 2 solutions here: To align the values while inserting them
Read the log files and get the entries between two dates
I want to extract some information from the access log file that matches a keyword and between two dates. For ex. I want to find log entries between two dates that contains text “passwd”. For now, I am using the following command but not getting the correct results: Date format is [22/Feb/2017:17:…
Linux shell script regex match
I have a text file. I want to get lines starting with specific format. I just want to get lines that have x/x/x format. x is a number. But this regex is not working. It is always giving no match : File is : Answer Don’t use bash if you can use a better tool: But if you have to