I’m new to bash scripting, I’m learning how commands work, I stumble in this problem, I have a file /home/fedora/file.txt Inside of the file is like this: What I wanted is to retrieve words between “[” and “]”. What I tried so far is : I can print the words between “[” and “]”. Then I wanted to put the
Tag: string
I am trying to replace a string in a file via shell script where a part of the string is unknown
I have tried a few ways with sed as below without success: I do not know the value behind “=” which can have up to 2 digits. Before and after the string there is a space, and the string always starts with “device.value=” PS: The file is a one liner with many values seperated through a space. I would appreciate
Convert char array of C into string of C++
I need to convert char array of C into string c++ but the char array is an element of struct. Code: This is my Structure in C and I want to access name[50] in c++ but for that I have to convert it into string. I have tried strcpy and memcpy. I am using ESL_BOOL status; and it is working
How do I copy regex matches from a file? Need to get all MAC addresses from log file
I have a linux dhcpd log that I need to get a list of only the MAC addresses. The MAC addresses are formatted like 00:ab:27:d8:dd:dd Using linux command line tools,parse INPUT file for MAC addresses and send to OUTPUT file. Where OUTPUT file is just a list of the MAC addresses, where then duplicate MAC addresses can be removed. I
Variable reset after scanf
I wrote the below function : I print the currentPlayer on any level to see what’s going on -> here what I get: Why the current player is 0 after scanf? I didn’t touch it. Answer The buffer location has only room for 2 characters and scanf puts an extra NUL character at end. Therefore you have a stack corruption
I need get a substring in Shell Script
i need help. I need get a substring in the next line the result must be: ttl 128 I hope you can help me! Thanks! Answer Try doing this : NOTE b is a word boundary s is a space + mean at least one or more preceding character -P switch is pcre advanced useful syntax for grep -o switch
ruby Array.inspect vs. Array[element].to_s
I’m working with an array, which we’ll call books, of complex objects, which we’ll call Book. The problem is when I call puts “#{books.inspect}”, ruby outputs a stream of binary (unreadable utf8 characters). However, when I call puts #{books[0].to_str}”, I get a brief, pretty output that describes the book in question. Not sure if it is relevant, but Book is