foo="Hello"
foo="${foo} World"
echo "${foo}"
> Hello World
In general to concatenate two variables you can just write them one after another:
a='Hello'
b='World'
c="${a} ${b}"
echo "${c}"
> Hello World
for finding a specific line in a file, have you considered using grep?
grep "thing I'm looking for" /path/to/my.file
this will output the lines that match the thing you're looking for. Moreover this can be piped to xargs as in your question.
If you need to look at a particularly numbered line of a file, consider using the head and tail commands (which can also be piped to grep).
cat /path/to/my.file | head -n5 | tail -n1 | grep "thing I'm looking for"
These commands take the first lines specified (in this case, 5 and 1 respectively) and only prints those out. Hopefully this will help you accomplish your task.
Happy coding! Leave a comment if you have any questions.
Use sed
Usage
$ cat file
Line 1
Line 2
Line 3
Line 4
Line 5
Line 6
Line 7
Line 8
Line 9
Line 10
To print one line (5)
$ sed -n 5p file
Line 5
To print multiple lines (5 & 8)
$ sed -n -e 5p -e 8p file
Line 5
Line 8
To print specific range (5 - 8)
$ sed -n 5,8p file
Line 5
Line 6
Line 7
Line 8
To print range with other specific line (5 - 8 & 10)
$ sed -n -e 5,8p -e 10p file
Line 5
Line 6
Line 7
Line 8
Line 10
Piping to will pass stdin as an argument to xargs cat, printing the file.cat
Alternatively try: .cat $( some command printing a filename )
The lines
if(!WIFSIGNALED(status) && !WIFEXITED(status))
waitpid(pid, &status, WUNTRACED);
won't work because waitpid() needs to executed at least once, and then it needs to be executed continually until the condition becomes false. That is, a do-while loop is needed:
do {
wpid = waitpid(pid, &status, WUNTRACED);
} while (!WIFEXITED(status) && !WIFSIGNALED(status));