Skip to content

Tag: unix

pipe command make standard input broken

I have two processes: t1.cpp and t2.cpp. t1.cpp and t2.cpp are simplified ,I want to describe the problem easily. After compiling t1.cpp and t2.cpp. I execute them in this way ./t1 | ./t2. Problems occur! cin >> x; in t2.cpp failed! I have no chance to type from the keyboard. It seems the pipe command i…

Bash Syntax Error syntax error: unexpected end of file

We are using the Bourne-Again Shell. What does this error mean?: syntax error: unexpected end of file Answer The single quoted string starting with is missing the closing single quote. SO’s syntax highlighting shows it, too. Maybe you wanted to backslash the quote? or there are double quotes missing too…

how can i cut one line on two on a cat /ect/passwd?

I’m trying to write a command that shows all odd lines of /etc/passwd: I’ve tried: but it didn’t work Is there a different way to obtain the result? Answer The step syntax is a GNU extension. sed ‘n;d’ should be the portable version of your sed invocation.

Unexpected behaviour of double quotes in bash script

I’ve created a variable which looks like this: If I print it to the terminal, using echo $firstAndLastLines, I get the following output: root bin daemon adm lp Privilege-separated SSH Account used by the trousers package to sandbox the tcsd daemon Norbert Fogarasi But, if I use echo “$firstAndLast…

sudo doesn’t work, but root user works [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack …

How to use sed to delete lines not containing pattern

I have a file as below: I need to delete all lines except the first line, which means that lines should not be deleted if it contains Thumb[any characters except /].jpg. I try to use sed to do this but I don’t know how to write the regex. I’ve tried like this: sed -i -e ‘.*Thumb^(/).jpg!d&#8…

How to paste a custom linux stdout into a JSON with Python?

I’m a beginner in Python and I’m trying to write a script that will take in a unix stdout file and convert it into a JSON format file. The format of the file is the following on every line: The path can contain whitespaces and backslash characters, an example is: Now my problem is that if I use th…