Skip to content

Tag: bash

What’s the purpose put a .so file before execution file?

I saw a execution method today. I know when putting a bash variable before execution command means to set that environment variable before execute command. But now, it is a share lib, what’s the purpose and function to put there? Answer The dynamic linker /lib/ld-linux-x86-64.so is special in that it can be r…

list only directory if contain a specific file name in bash

Hel lo everyone, I need help with bash commands. Here is the deal : I have several directories : such as and a /path_to_this_file/file.txt : that I use such as : then I can list all content in the paths BUT I would like to do a ls only for the path2 that does not have a file2 into their

Finding linux users with a bash script

i am newbie in bash-scripting and linux. I want to write a script to get a username from the terminal and say whether that username is on the passwd or not. i wrote and tried below script but it doesn’t work. help me that what i can do. how i can define a variable to read a string from termnial.

Creation of brace sequence not working in bash

I must create a sequence of numbers using the number of elements that an list has. arr1=(1 2 3 4 5 6) I thought about the following expression in order to do so, but it is now working. echo {0..$(expr ${#arr1[*]} – 1)} {0..5} # output The correct output should be: 0 1 2 3 4 5 Could anyone explain

Copy the newest two files and append the date

I’m looking for a way to copy the newest .gz files I have in Dir A to Dir B, and append the date to that files. Example: Dir A cinema.gz radio.gz cars.txt camera.gz Dir B cinema.gz.20200310 radio.gz.20200310 Using following command I can copy the newest .gz files to dirb cp $(ls -1t /dira *gz | head -2)…

Text input on command line does not match PS1

I set a custom PS1 to expand the current directory. That works well, however, the text input does not match the PS1 length. Instead of the input being at the “>” I set at the end of PS1, it is instead only about 10 characters in from the line start. This only happens when I’m inputting a …

How to insert char in mathed lines in a file

For example, I have a file with the content: I want to add “_1” in all the lines with “a : “, and get the result as: Are there any ways by bash commands Answer Your spacing is unclear, whether you have “a : …” or “a: …”. You also have what appears si…

Shell script: Using own IP adresss as variable

I have to write a shell script which initializes docker swarm. I need to pass the own IP address as argument: How can I do this dynamically? I know the ifconfig command, which allows me to see the IP, but I can not pass the whole thing as variable. It should look like this Answer The following command will re…