[Solved] Replacing string with variable with Groovy and SED command

In Groovy variable/expression substitution inside of strings (interpolation) only works with certain types of string literal syntax. Single quote syntax (‘content’) is not one of them. However, if you replace the outer single quotes with double quotes (“content”) then you should get the interpolation effect you are looking for: def sDescription = “foo” def sedCommand … Read more

[Solved] The head of the snake is a couple points away from the body (c++ game) [closed]

I think your problem is probably partly in the get_next_position_to function, where you increment the position of the body part passed into the function. I think this should probably only add. The ‘RIGHT’ case also modifies both X and Y. position_t get_position_next_to(body_part_t *part) { position_t pos; switch(part->dir) { case UP: initialize_position(&pos, part->pos.x, part->pos.y + 1); … Read more

[Solved] Search for specific characters in specific positions of line

To search for “foo” at position 42: egrep ‘^.{42}foo’ You can run a command like this multiple times on your input: egrep ‘^.{42}foo’ inputfile.txt > lineswithfoo.txt egrep ‘^.{42}bar’ inputfile.txt > lineswithbar.txt … or as a loop: for pattern in foo bar qux; do egrep “^.{42}$pattern” inputfile.txt > lineswith$pattern.txt done solved Search for specific characters in … Read more

[Solved] Practice Linux Shell Scripting

Consider adding a counter, bump it up on every line, and print the counter with every line. Also note fixes to set log_file, update to read command. log_file=”/home/user/log.txt” line_no=0 while read -r line do line_no=$((line_no+1)) printf “%d. %s\n” $line_no “$line” done < “$log_file” One alternative to consider is to call the nl utility, which performs … Read more

[Solved] copy files to remote servers but in a directory which belongs to some other user?

Since you hint on having sudo configured for your connecting user david, the simplest thing you can do is use elevated permissions to copy the file and set its an ownership to goldy through owner parameter of the unarchive module: – name: copy and untar latest tasks.tar.gz file unarchive: src: tasks.tar.gz dest: /data/files/tasks/ owner: goldy … Read more

[Solved] Install glibc 2.15 in Red Hat 6.5 [duplicate]

Can I install glibc from some repo? Not likely: distributions usually don’t ever update the major/minor version of glibc from the one they originally shipped with, because the likelihood of breaking applications is too great. You may have to build glibc-2.15, or better current glibc-2.24 from source and install it into non-default location. See this … Read more

[Solved] Linux programming in C++ [closed]

The Unix API is C (as is the Windows API); any calls into Unix will look like C. That doesn’t stop you from using C++, however: if the function requires a char const*, for example, you can call std::string::c_str() on an std::string. Whether you want the Unix function (e.g read()) or the C++ (>> on … Read more

[Solved] Unix Command | ps [closed]

Copied from man ps: -u userlist Select by effective user ID (EUID) or name. This selects the processes whose effective user name or ID is in userlist. The effective user ID describes the user whose file access permissions are used by the process (see geteuid(2)). Identical to U and –user. Meaning: it prints all the … Read more