Skip to content
Advertisement

xterm keep page from less in terminal after exit

I often view files using less and want to remember what i have just seen in the file. However when I quit less by pressing the q key my xterm window removes the page of less showing the file and only shows my command prompt. How do I keep the less output on my terminal when I quit? Answer less

linux shell title case

I am wrinting a shell script and have a variable like this: something-that-is-hyphenated. I need to use it in various points in the script as: something-that-is-hyphenated, somethingthatishyphenated, SomethingThatIsHyphenated I have managed to change it to somethingthatishyphenated by stripping out – using sed “s/-//g”. I am sure there is a simpler way, and also, need to know how to get the

Mach-O’s two-level namespace symbol resolution in ELF/linux

Anyone know of an equivalent to Mach-O’s two-level namespace symbol resolution in ELF/linux? I want code that links to lib+sym, not sym. I’m trying to do what could best be described as precompilation of what normally would be a JIT compilation. I’d like to get a compile time binding of symbols, that normally would be done by a dlopen/dlsym. However,

finding unique values in a data file

I can do this in python but I was wondering if I could do this in Linux I have a file like this I want to find all the different types of values in the 3rd column by a particular username lets say name 1. grep name1 filename gives me all the lines, but there must be some way to

Changing working directories in Linux shell in a C program

My goal is to write a C program that is like a basic shell for Linux. I have everything working except changing working directories. I have tried the system() for input strings for cd and nothing happened. I also tried chdir(“tokened string”) and also no luck. Anyone have any ideas? This is part of my code: Is it possible to

Determine programmatically if a program is running

In C, how can I find out programmatically if a process is already running on Linux/Ubuntu to avoid having it start twice? I’m looking for something similar to pidof. Answer You can walk the pid entries in /proc and check for your process in either the cmdline file or perform a readlink on the exe link (The following uses the

sed replace with hex

UTF-8 file test.txt: hex is sed s/A/B/g test.txt works sed s/x41/B/g test.txt does not work Some characters are unprintable so I must use their hex, A is just an example. Answer the shell preprocesses it, use single quotes.

CPAN giving all sorts of errors on ubuntu

I am just trying to run a simple perl program to import data from xml and export it to database. Use Mysql; did not work, so I used DBD::mysql instead after failing to get Mysql.pm from cpan. However, I am unable to install anything. I am trying to install xml parser module, but cpan gives these errors no matter what

Getting cannot allocate memory error

I am getting this error in my program… ulimit -a gives the output: The amount of memory I’m trying to protect is 60 MB. Can someone tell me what is the problem and how it can be solved? Answer Given the error message, you probably got an ENOMEM error, and looking at the error code, this does not necessarily mean

Echo to both stdout and stderr

I have a probably pretty easy beginner question: How do I echo from a shell script into both stdout and stderr? I know that I can echo to stderr echo “foo” 1>&2 but I need the output in both. I tried some Googling but nothing worked. Answer This should do it

Advertisement