Skip to content

Tag: linux

Linux rename with a variable character?

I have a list of files eg. How do I use rename to be like this: I am new to this and having trouble understanding the examples online. I want to do something like the following where the ? is a variable character: Answer ? mean “any character”. So, your page-1.htm will be rename because it’s…

How to reproduce the accept error in Linux

I’m learning Unix Network Programming Volume 1, I want to reproduce the accept error for RST in Linux. server: call socket(), bind(), listen(), and sleep(10) client: call socket(), connect(), setsockopt() of LINGER, close() and return server: call accept() I think that the 3rd steps will get an error li…

How to pass “-L” to an awk script?

I am trying to write an awk script that accepts -L as an argument. As an example to show you what I want, here is a simple awk script called awktest: If I run this from shell: I get as output: Which is what I expect. It seems to work for anything I put in except -L. If I run:

Segmentation fault when maping /dev/mem

I’m trying to mmap a memory from my FPGA on a linux running on my Zedboard SoC. I can read the contents correctly using devmem on the command line, but when trying to read it through C I get a segmentation fault. The barebones code shown below throws the segmentation fault when trying to print the conte…

Return custom process command in Ubuntu

I want to launch the following script in bash and the “ps -A | grep php” command returns something if the script is running. Is there any way to customize this “php” command with another name? I want to write and “ps -A | grep php” should return nothing, but “ps -A | …