Questions tagged as 'bash'

1
answer

How to call a function inside a PHP script from the command line

I want to know if I can call a function inside a script from the command line, using for example: $ php script.php minhaFunção() <argumento> In this case, the function is not inside a class (do I need to be?) Below my code: <?...
asked by 11.08.2017 / 04:09
1
answer

Installing MySql on Linux in a programmatic way. How to set the password?

I'm creating a sh file to start a Linux programming environment to automate this boot process. I usually just run the following command lines and during the MySql installation process I have to choose the ROOT user password. This is the code:...
asked by 30.06.2016 / 02:26
1
answer

Check if user exists

How can I in bash check if a user exists, but in a way that script works on multiple systems? A limited example: grep <username> /etc/passwd Does not work on systems that use NIS or LDAP to manage users.     
asked by 25.03.2015 / 14:20
2
answers

Substring in Bash

I'm trying to get a portion of a line in a text files in bash but instead of the text 'field1' I wanted to use a variable. But it is not working. Suggestions WORKS: NomeVar=$(cut -d ":" -f 1 <<< "$(awk /campo1/ { print substr($0,48...
asked by 13.01.2015 / 12:46
1
answer

How to treat avariety in bash?

I'm having a problem, I'm doing a bash script to run using crontab, which syncs my ssd files with the hd and dropbox. Script: #!/bin/bash - PC_DIR="~/Programming" DROP_DIR="~/Dropbox/Programação" PC_FILES="$(find ${PC_DIR} -follow)" DROP_...
asked by 20.12.2017 / 04:40
1
answer

Mass file encoding conversion on linux

Hello, I need to do the file encoding conversion to utf-8 since the application will migrate from server. In this application I have files with several encodings in fact, some in utf-8, others in iso-8859-1 and still files in windows-1252....
asked by 22.09.2017 / 14:22
1
answer

Shell Script for file and directory localization

I would like someone to help me create this script correctly, in case it is to create a script that you type the name and directory of a file and then indicate if it was located or not and that generates this type of output on the screen $ ....
asked by 13.04.2017 / 18:53
1
answer

Compare files from a directory with md5sum and shellscript

Good morning! I'm studying shellscript and an exercise asks for a scan of files in the current directory and md5 hashes to be computed. It also asks that if there are identical files by comparing hashes, these files are printed. The code I wa...
asked by 29.03.2017 / 15:43
1
answer

How to change the Cartesian coordinates of files, in an automated way

I have a certain folder with several files, and these in turn, contains in its interior description of Cartesian X and Y coordinate points. However, I want to replace these points automatically and dynamically, ie use while to run all...
asked by 18.06.2017 / 15:08
3
answers

Transform date format DD / MM / YY in MM / DD / YY in Shell Script

The script reads the date of a .txt in DD / MM / YY format, and needs to convert it to MM / DD / AA format with Bash, Sed, or AWK.     
asked by 14.10.2016 / 00:12