All Questions
Tagged with command-line unix
416
questions
1
vote
0
answers
56
views
How to detox filenames in a bash script with no errors posted?
OS: Kubuntu 22.04.4 LTS x86_64
detox 1.4.5
To display above:
neofetch --stdout |grep 'OS:'
detox -V
Here is a toxic filename, starts with s1:
s1 Ä Ö Ü - ä ö ü Science & < > " 1 \ 2 ⁄ 3 ...
0
votes
1
answer
236
views
Broken pipe, write error: An epidemic of unnecessary output
In the last few months, a problem has been spreading across my systems. That of broken pipe errors:
# Solution:
# silenced by replacing /bin/bzip2 -> bzip2-reference
# to /bin/...
2
votes
1
answer
51
views
How can I use the last changed file as an argument in linux?
I'm thinking of using the last changed file as an argument to commands like ls, echo, or cat, is there a simple and efficient way? this question arose when I was faced with analyzing the latest log ...
0
votes
3
answers
71
views
display path to files with same names
with this command in Terminal:
ls -R |sort | uniq -d | sort -r
I can display a list of files with the same names located in the running directory and subdirectories.
But I would like to display also ...
0
votes
0
answers
54
views
Synchronize files based only on the existence of unique filenames (Mac OS / Unix)
I am looking for a way to synchronize two folders/volumes based only on whether a filename exists in folder A but not in folder B. I want the sync to completely ignore path and modification dates. ...
0
votes
1
answer
2k
views
Unix: zip folder ignoring folder structure and excluding a subdirectory
I want to create a zip ignoring the folder structure, and excluding the content of a specific subfolder.
I have tried:
zip -rj /path/to/target.zip /path/to/source -x "/path/to/source/subfolder/*&...
1
vote
2
answers
793
views
Unix cat and zip together
What I'm trying to do seems simple enough, but I can't get it to work, nor can I find anything on Google referring to how to do this?
I want to first cat a bunch of files, then zip the resulting file ...
0
votes
0
answers
109
views
Batch file using WinSCP won't execute UNIX shell script that assigns variables to output of "more" command
I am working with a Batch script that uses WinSCP to transfer files from an UNIX machine to a windows machine.
To achieve this, WinSCP has to call shell scripts on the UNIX side.
There is one shell ...
0
votes
1
answer
742
views
UNIX or Linux sort: only sort on the first part of an entry
I'm working on a complicated grep, something like grep -E -i "first|next" *.txt, and I get results like:
logs.10.txt:2022-10-07 10:33:05.6673 | ClassName | [Info] | Inside function first(), ...
1
vote
0
answers
255
views
Attempts to Zip files by date not working as expected
I am trying to zip up a bunch of files, but only those created on a certain date. I'm trying to use the -t option, but it's not finding the files that I can clearly see are there.
This is a sample of ...
1
vote
1
answer
249
views
zsh alias for running the most recent matching history item
I'd like to create an alias in zsh that runs my last terminal command beginning with node. I can run that command with !?node, but I can't create an alias with alias N='!?node'. How can I make this ...
0
votes
2
answers
389
views
Accidentally made an alias for a pre-existing command on OS X
I was toying around with aliases and made an alias to take me to the directory where I store all my bash projects via the cd command.
However, I used 'bash' as a name for the alias. Now when I run all ...
0
votes
1
answer
459
views
How to do a recursive filename `find` from the shell using a glob pattern with "set braces"
From the shell, I'd like to recursively search a directory for a given glob pattern. But I want to use set-braces-syntax in my pattern:
find ~/path/to/dir -name '*.{h,m}'
Here I'd like to recursively ...
1
vote
3
answers
3k
views
UNIX/Linux: What's the file permission number?
When I ask for file permissions on a Windows-10 WSL Ubuntu app, I do:
ls -ltra
And I get information like:
-rwxrwxrwx 1 scampsd scampsd 42034 Mar 29 15:26 Filename.cs
drwxrwxrwx 1 scampsd scampsd ...
1
vote
1
answer
1k
views
Keep Color output with grep at systemctl status
I'm trying to get the original color of the output of this command with grep:
sudo systemctl status telegraf | grep -e ● -e Active
Output of command
with this command the output is red, but i want it ...
1
vote
1
answer
235
views
Why do /dev/input/eventX permissions differ depending on how X server is launched?
I have a simple command line binary written in C on Debian that reads USB gamepad input on /dev/input/eventX and shows which gamepad buttons are pressed. I do this by opening and reading /dev/input/...
-2
votes
1
answer
1k
views
How I remove or erase ls -l | head -3 | tail -l to start over. What command I type?
How do I remove or erase
ls -l | head -3 | tail -l
to start over. What command should I use?
Since my ls -l | head -3 | tail - l has double exit1.sh, exit2.sh.it isn’t same picture instruction
1
vote
1
answer
59
views
What makes a new command line (i.e. user@machine:~/directory$) appear in the terminal?
I am writing a Python program and when I interrupt this program, it unfortunately prints lines after the new dollar line has been printed. It looks something like this:
[INFO]: Program finishing...
...
0
votes
1
answer
2k
views
Is there a way to make Unix diff -r compare only differences in filenames, but not check if any single file actually differs?
I need to compare two large directories with a lot of files in them. I tried using:
diff -r Directory1 Directory2
but unfortunately the process is really slow due to the amount of files and their ...
0
votes
3
answers
314
views
Is there an elegant way to move all sub-directories in the current directory to a new sub-directory?
I often run into the following situation. I am in a directory with several sub-directories like so
$ls
a b c d
I would like to archive directories a-d by moving them into a new directory at the same ...
0
votes
2
answers
1k
views
Sorting the output of the Windows tree command?
I typically use bash in MSYS2 on Windows, however, I have to inspect a massive network share (on which the MSYS2 version of tree chokes - as in, takes forever), and so I'm forced to use the Windows ...
0
votes
1
answer
511
views
How are bash variables containing a file path with non-ascii characters and spaces used as input for commands, cat, exiftool, etc.?
I have set a variable:
myvar='/home/user/shares/D/iPhoto\ Library\ Main.migratedphotolibrary/Data.noindex/2002/102008\ \ name\ lname\ event/PICT0002_2_face0.jpg'
Then tried to cat this variable:
cat ...
1
vote
0
answers
479
views
grep and awk are not displaying output in terminal
When trying to grep Record in .txt file simply
$ grep 'Record' file.txt
$
it goes to the next line without any output or error (I've tried to write output in file, but it is empty)
I've tried also to ...
0
votes
0
answers
46
views
I need to do bulk find and replace
I have file1.txt with these lines
abc
def
ghi
file2.txt with these lines
jkl
mno
pqr jkl
jkl
mno mno mno
pqr
I want to write a script that replaces all occurrences of the string jkl in file2....
0
votes
1
answer
2k
views
How to use "find" to print the path instead of "grep" in case of matching file contents
For example, I need to print the paths of all the user's files that contain the word hello.
Must use find
Use the find command to search, and grep to print the path:
find ~ -type f -exec grep -lis &...
0
votes
1
answer
125
views
macOS|Unix combine multi-line .txt file into single line with no spaces? (no line breaks)
I've been looking around & I cannot seem to find a command or regex that will do a simple command of combing all linebreaks & spaces in a text file into one line. most of them either add some ...
0
votes
0
answers
208
views
Terminal color codes not working as expected
I am using the following code in my ~/.bash_profile following some online blogs.
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
export TERM="xterm-color"
export PS1='\[\033[1;32m\]$...
1
vote
1
answer
2k
views
How to keep Midnight Commander running after you open a file?
mc (Midnight Commander) is an excellent CLI file manager, but I have really struggled with this problem:
How to get mc to keep running after you choose to open a file?
For example, when I navigate to ...
0
votes
2
answers
632
views
Execute commands from a remote path
When we execute i.e. ls command the terminal application search for that ls on our PATH variable. The PATH usually contains a number of system directories plus some user specific directories. So a ...
2
votes
0
answers
398
views
accesstime on macOS Catalina 10.15
Suppose you own a file system on a unix machine, and
you would like to know which of the regular files on this system
you have accessed within some interval.
("Regular file" means it is not ...
3
votes
1
answer
2k
views
How reliable is the randomness of the shuf command?
I ran the following command to generate 1 billion random numbers:
time shuf -i 1-1000000000 > "SHUF TEST 1"
To my surprise it was able to do this in less than 10 mins. I then ran the ...
0
votes
1
answer
98
views
Why does my bash script not navigate properly?
My final goal for this script is to:
Visit folder in loop
find the descriptor.mod
Rename it to its folder name
Relocate it to a specific folder
repeat
Currently, when I am trying to visit the folder ...
1
vote
0
answers
29
views
sorting out files to different directories from a main directory
I have numerous files I am trying to move from a main directory in to separate directories which have multiple sub-directories inside.
Example file naming conventions 1SA_1BA_1W.out, 2SA_3BA_3W.out, ...
2
votes
2
answers
1k
views
Can I use bash brace expansion in for loop?
I have some files in directory: touch dir1/dir2/bad\ name{1..4}. I would like to move those files (bad name1 - bad name4) from dir2 to dir1, as well as rename them at once. Because these files have ...
1
vote
1
answer
132
views
Why do some applications return if already running, and otherwise block?
When using a command line to open multiple tabs in a GUI application, often the first command blocks (waiting until the application is closed) but the subsequent commands each return immediately (...
2
votes
3
answers
522
views
Command line: merge and keep all info from the two files
How to merge and keep all info from the two files as such ?
$ cat file1.txt
apple
cool
dude
flan
$cat file2.txt
apple
ball
cool
dude
elephant
for a result as such :
$cat ...
0
votes
2
answers
113
views
Speeding up find command result with folder exclusions
I have the following folder structure:
Approvals_Share
1 CUST APPROVAL
2 LICENSE APPROVAL
CANADA INSCRIBE
z-remove
There are multiple subfolders and illustrator files “.ai” inside ...
1
vote
1
answer
1k
views
How to find all files,with substring, e.g. xyz (caseinsensitive) in filename within particular type (*.txt) using linux command line?
I have some bunch of files, which has "xyz" in the filename, This "xyz" can be case insensitive, e.g. "XYz" or "xYz". Wish to display all possible combination of the files in from current working node
2
votes
4
answers
10k
views
Bin folder for Windows 10
I'm trying to replicate a UNIX bin folder on my Windows 10 PC. I have created a folder located at "C:\bin" and added it to my PATH variable. However, I'm not really sure as how to implement it any ...
3
votes
2
answers
919
views
"watch" command not displaying "tree" command output with Unicode bars and dashes
When executing
watch tree .
I get output as follows
Every 2.0s: tree . macbook.local: Fri Dec 20 16:23:33 2019
.
hello.txt
hi.txt
hmm.c
subdir
...
2
votes
2
answers
1k
views
Is there a way to make sed not wait for complete lines?
sed seems to process its input line by line. This is usually not a problem, but if you have really long lines, you can run into issues. For example, the following command never outputs anything:
{ ...
4
votes
2
answers
13k
views
How to run the file command recursively
I'm trying to get information about the types of all the files in a given directory tree. Running file * in the current directory works well enough, but it doesn't traverse into sub-directories and ...
2
votes
1
answer
1k
views
Where did my files go after using mv command?
All my .c source files and a Readme file were in a subdirectory called assignment2 in a directory called Assignment2. Originally, from assignment2 directory:
$ ls
corrupt.c decode.c encode.c fix.c ...
0
votes
1
answer
230
views
Replace files recursively
I have a deeply nested directory called MyProject which contains dozens of git repositories. Each of those repositories contains, somewhere, a directory called utils which contains a file called ...
0
votes
2
answers
76
views
control seq for errors in unnamed pipe
$ awk -v f=<(cmdmayfail) -e 'BEGIN { r = getline < f ; print r }'
-bash: cmdmayfail: command not found
0
In the above-unnamed pipe example, awk will not know the error from the unnamed pipe.
$ ...
3
votes
1
answer
1k
views
Bash autocomplete with wildcard
I would like to type in the terminal like I do in emacs:
emacs 2019-*subject*
When I hit Tab I get the first match:
2019-08-03-subject.markdown
What I would like is for it to show me the options ...
0
votes
1
answer
1k
views
Running several asynchronous tasks and get their outputs and exit codes in bash
I have to run a bunch of commands asynchronously and as soon as one finishes, I need to perform actions according to its exit code and output. Note that I can't predict how for long any of these tasks ...
0
votes
0
answers
1k
views
How to recover the System after rm -r / -command string
I'm willing to learn how to recover the System after system administrator (root user) have hit "rm -r /" -command string by accident after learning some new nice commands. My customer is humanist ...
1
vote
1
answer
216
views
How to make command line tool “ctpu” be recognized by my terminal?
I downloaded the ctpu command-line tool made by Google. This tool makes it easy to set up and run Cloud TPUs for deep learning projects. I successfully downloaded the tool to my ~ directory (Users/...
1
vote
2
answers
2k
views
using 'rm -rf' safely [duplicate]
I'm fairly new to unix and I have seen a lot of warnings against using rm -rf.
Example: "But, always double check before you use rm -rf command, if you by mistake give this command in your home ...