60 Answered Questions for the topic UNIX

06/17/19

#### What is the Windows equivalent of the Unix command cat? ?

I want to do exactly what unix "cat" does, but on my PC. Is there a simple equivalent command for the Windows command line? Specifically I want to create a file from all the files of a given type... more
Unix Pi Algorithm

06/03/19

#### What is the fastest way to get the value of π?

I'm looking for the fastest way to obtain the value of π, as a personal challenge. More specifically, I'm using ways that don't involve using #define constants like M_PI, or hard-coding the... more
Unix Shell Vim

06/03/19

#### Delete newline in Vim?

Is there a way to delete the newline at the end of a line in Vim, so that the next line is appended to the current line? For example: Evaluator<T>(): _bestPos(){ } I'd like to put this... more
Unix Linux Bash

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
Unix Linux Diff

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
Unix Linux Bash

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
Unix

05/29/19

#### Unix: How to check permissions of a specific directory?

I know that using ls -l "directory/directory/filename" tells me the permissions of a file. How do I do the same on a directory? I could obviously use ls -l on the directory higher in the... more
Unix Bash Shell

05/27/19

#### How to represent multiple conditions in a shell if statement?

I want to represent multiple conditions like this: if [ ( $g -eq 1 -a "$c" = "123" ) -o ( $g -eq 2 -a "$c" = "456" ) ] then echo abc; else echo efg; fi but when I execute the script,... more
Unix File Newline

05/26/19

#### Why should text files end with a newline?

I assume everyone here is familiar with the adage that all text files should end with a newline. I've known of this "rule" for years but I've always wondered — why?

05/26/19

#### How can I extract a predetermined range of lines from a text file on Unix?

I have a ~23000 line SQL dump containing several databases worth of data. I need to extract a certain section of this file (i.e. the data for a single database) and place it in a new file. I know... more

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

#### Remove carriage return in Unix?

What is the simplest way to remove all the carriage returns \\r from a file in Unix?
Unix Terminal Cat

05/26/19

#### Concatenate multiple files but include filename as section headers?

I would like to concatenate a number of text files into one large file in terminal. I know I can do this using the cat command. However, I would like the filename of each file to precede the "data... more
Unix Arrays Bash

05/26/19

#### Loop through an array of strings in Bash?

I want to write a script that loops through 15 strings (array possibly?) Is that possible? Something like: for databaseName in listOfNames then # Do something end
Unix Grep

05/26/19

#### grep a tab in UNIX?

How do I grep tab (\ ) in files on the Unix platform?
Unix Linux Shell

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/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?
Unix Linux Windows

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
Unix Bash File

05/21/19

#### How to split a large text file into smaller files with equal number of lines?

I've got a large (by number of lines) plain text file that I'd like to split into smaller files, also by number of lines. So if my file has around 2M lines, I'd like to split it up into 10 files... more
Unix Shell Sh

05/19/19

#### How to read a file into a variable in shell?

I want to read a file and save it in variable, but I need to keep the variable and not just print out the file. How can I do this? I have written this script but it isn't quite what I needed: ... more

05/18/19

#### How can I reverse the order of lines in a file?

I'd like to reverse the order of lines in a text file (or stdin), preserving the contents of each line. So, i.e., starting with: foo bar baz I'd like to end up with baz bar foo Is there... more
Unix Linux

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)?
Unix Linux Bash

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?
Unix C Linux

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
Unix Linux Grep

05/14/19

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

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

## 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.