Questions tagged as 'bash'

1
answer

How to list the symbolic links of a folder in Linux?

I'm using a deploy tool in PHP. When I use the command, some symbolic links are created for certain folders. How do I run this command on a Linux server, I would like to know if there is any command to list all the symbolic links created...
asked by 06.06.2016 / 14:44
2
answers

script does not write to file

I am mounting a bash script as follows: #!/bin/bash destfile=/home/user/teste.txt array=($(ls 20151* |awk '{ print $9 }')) n=${array[@]} echo "$n" > "$destfile" However, when you run the script, the test.txt file is created, but empty....
asked by 12.01.2016 / 13:06
1
answer

How do I get size of an array string in the shell script?

I have a string that I pass as a parameter, for example: "2,3,4,5" To get every item of it I do: #!/bin/bash for ((i=1; i<=4; i++)) do echo "$1" | cut -d "," -f $i done But I would like to make the loop iterate up to the m...
asked by 14.09.2018 / 20:00
3
answers

Remove everything after? in file name

Hello I'm trying to rename a large amount of files in linux, but I'm not able to hit the command. The case is as follows: I have several files in a directory and its subdirectories that have the following name format nome_do_arquivo.ext?...
asked by 09.05.2018 / 16:35
1
answer

How to redirect all the bash script inside the script itself?

I need to play the output of it in a file instead of playing in the standard output that is the screen but without having to explicit with the command >> in the terminal, I want the script itself to do this.     
asked by 23.07.2018 / 00:42
2
answers

How to renumber recursively numbered files, giving name to other files

What I am currently looking to do is rename all files in a folder, where there are also other files of different format. See the example: PASTA - BEFORE 1.txt 2.txt 3.txt Daniela.jpg Amanda.jpg Lucia.jpg What I can not do is exactly...
asked by 31.01.2018 / 21:51
3
answers

Replace output of a command with a custom message

I am creating a script where at the end of it I execute a command that displays a very large output of information. Is it possible to replace this output? That is, instead of it showing the standard output show only one message eg Connected. ?...
asked by 21.09.2017 / 14:13
2
answers

How to cut a suffix of an expression in bash (egrep / sed / etc)

I am making a script that works with directories that have suffixes defined and separated by ".", for example "folder.teste.git" or "things.var" and would like to take as a variable only the prefix eliminating the last one part (eg the name "fol...
asked by 04.08.2017 / 00:37
1
answer

Redirect function time value to file

I'm trying to use the time function on the terminal. When I try to use only to display always I have the expected return. Command: time ./main Output: real 0m0.119s user 0m0.113s sys 0m0.006s But when I try to redirect thi...
asked by 03.05.2016 / 00:59
1
answer

Script to exchange place string with another string

I have the file /etc/udev/rules.d/70-persistent-net.rules that have such interfaces: SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="1c:af:f7:e7:a4:3c", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0" S...
asked by 21.07.2015 / 20:28