119 Answered Questions for the topic Linux

Linux Shell Tar Archive

06/04/19

#### Shell command to tar directory excluding certain files/folders?

Is there a simple shell command/script that supports excluding certain files/folders from being archived? I have a directory that need to be archived with a sub directory that has a number of very... more

06/04/19

#### Why do you need to put #!/bin/bash at the beginning of a script file?

I have made [Bash][1] scripts before and they all ran fine without this at the beginning. What's the point of putting it in? Would things be any different? Also, how do you pronounce #? I know... more

06/02/19

#### Extract file basename without path and extension in bash?

Given file names like these: /the/path/foo.txt bar.txt I hope to get: foo bar Why this doesn't work? #!/bin/bash fullfile=$1 fname=$(basename $fullfile) fbname=${fname%.*} echo... more
Linux Unix Diff Bash

05/30/19

#### Given two directory trees, how can I find out which files differ?

If I want find the differences between two directory trees, I usually just execute: diff -r dir1/ dir2/ This outputs exactly what the differences are between corresponding files. I'm interested... more
Linux Unix Bash Grep

05/29/19

#### How can I format my grep output to show line numbers at the end of the line, and also the hit count?

I'm using grep to match string in a file. Here is an example file: example one, example two null, example three, example four null, grep -i null myfile.txt returns example two null, ... more
Linux Find Shell

05/28/19

#### How to exclude a directory in find . command?

I'm trying to run a find command for all JavaScript files, but how do I exclude a specific directory? Here is the find code we're using. for file in \$(find . -name '*.js') do java -jar... more

05/28/19

I am trying to get a Python script to run on the linux server I'm connected to via ssh. The script uses mysqldb. I have all the other components I need, but when I try to install mySQLdb via... more

05/27/19

#### Use Matlab Raspberry PI Support Package function in Simulink as Matlab Function Block?

I'm new to Matlab and Simulink and I need to get a simulation run on the Raspberry PI. For interaction I use the Raspberry PI Support Package of Matlab. I use the following code to open the... more
Linux Unix Makefile

05/26/19

#### In Unix, can I run 'make' in a directory without cd'ing to that directory first?

In Unix, can I run 'make' in a directory without cd'ing to that directory first?

05/26/19

#### How to assign name for a screen?

I'm using the screen multiplexer tool on the command shell and open a lot of screens. I then forget which process ID associates with which task. I would like to set a name for a screen but can't... more

05/26/19

#### Why does the C preprocessor interpret the word "linux" as the constant "1"?

Why does the C preprocessor in GCC interpret the word linux (small letters) as the constant 1? test.c: #include <stdio.h> int main(void) { int linux = 5; return 0; } Result of... more
Linux C++ G++

05/24/19

#### usr/bin/ld: cannot find -l<nameOfTheLibrary>?

I'm trying to compile my program and it returns this error : usr/bin/ld: cannot find -l<nameOfTheLibrary> in my makefile I use the command g++ and link to my library which is a symbolic... more

05/22/19

#### What does "opt" mean (as in the "opt" directory)? Is it an abbreviation?

What does "opt" mean (as in the "opt" directory)? I commonly see this directory in Unix systems with development tools inside. Is it an abbreviation?
Linux Unix Windows Bash

05/21/19

#### How to convert DOS/Windows newline (CRLF) to Unix newline (LF) in a Bash script?

How can I programmatically (i.e., not using vi) convert DOS/Windows newlines to Unix? The dos2unix and unix2dos commands are not available on certain systems. How can I emulate these with... more

05/20/19

#### How to determine whether a given Linux is 32 bit or 64 bit?

When I type uname -a, it gives the following output. Linux mars 2.6.9-67.0.15.ELsmp #1 SMP Tue Apr 22 13:50:33 EDT 2008 i686 i686 i386 GNU/Linux How can I know from this that the given OS is... more

05/17/19

#### Kill detached screen session?

I learned from somewhere a detached screen can be killed by > screen -X -S [session # you want to kill] kill where [session # you want to kill] can be gotten from > screen -ls . But this... more
Linux Command Line

05/17/19

#### Linux command to print directory structure in the form of a tree?

Is there any linux command that I can call from a Bash script that will print the directory structure in the form of a tree, e.g., folder1 a.txt b.txt folder2 folder3
Linux Io Bash File Io

05/17/19

#### How to redirect output to a file and stdout?

In bash, calling foo would display any output from that command on the stdout. Calling foo > output would redirect any output from that command to the file specified (in this case... more
Linux Cp

05/16/19

#### How do I copy folder with files to another folder in Unix/Linux?

I am having some issues to copy a folder with files in that folder into another folder. Command cp -r doesn't copy files in the folder.
Linux Unix

05/16/19

#### How to list all users in a Linux group?

How do I list all members of a group in Linux (and possibly other unices)?
Linux Unix Bash Command

05/16/19

#### How can I recall the argument of the previous bash command?

Is there a way in Bash to recall the argument of the previous command? I usually do vi file.c followed by gcc file.c. Is there a way in Bash to recall the argument of the previous command?

05/14/19

#### How to extract images from Word Document from Linux?

Is there a (Linux) command-line tool to extract all the images from a MS Word document, (preferably one that could handle the .docx format)?
Linux C Unix File Io

05/14/19

#### C fopen vs open?

Is there any reason (other than syntactic ones) that you'd want to use FILE *fdopen(int fd, const char *mode);or FILE *fopen(const char *path, const char *mode);instead of int open(const... more

05/14/19

#### Remove a symlink to a directory?

I have a symlink to an important directory. I want to get rid of that symlink, while keeping the directory behind it. I tried rm and get back rm: cannot remove 'foo'. I tried rmdir and got... more
Linux Unix Grep

05/14/19

#### How can I exclude directories from grep -R?

I want to traverse all subdirectories, except the "node_modules" directory.

## Still looking for help? Get the right answer, fast.

Get a free answer to a quick problem.
Most questions answered within 4 hours.

#### OR

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.