Posts

Showing posts with the label shell

Sharing PATH Variable Windows Subsystem for Linux (WSL) [on hold]

Sharing PATH Variable Windows Subsystem for Linux (WSL) [on hold] So I am trying to link the PATH variables for Java (and Python) to the Windows Linux bash shell I've tried following the directions on here: https://blogs.msdn.microsoft.com/commandline/2017/12/22/share-environment-vars-between-wsl-and-windows/ for /p with the path that I already have on windows: C:Program Files (x86)Common FilesOracleJavajavapath C:Program Files (x86)Common FilesOracleJavajavapath I did everything the same except first define TRANSLATABLEPATH as my the linux mnt path and then when im in cmd, the windows path What am I doing wrong? Edit: See comment but I basically set TRANSLATABLEPATH and export WSLENV=TRANSLATABLEPATH/p Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit th...

bash: Get last line of a huge gziped file

bash: Get last line of a huge gziped file In a database backup process I generate a text dumpfile. As database is quite huge, dump file is huge too so I compresses it with gzip. Compression is done inline while dump is generated (thanks Unix pipe !). At the process end, I check dump file validity by watching the last line and check the "Dump completed" string presence. In my script I do it by extracting last line into a variable: str=`zcat ${PATHSAVE}/dumpFull.sql.gz | tail -n1` As database dump file is huge (currently more than 200Gb) this end process check take huge time to run (currently more than 180 minutes). I'm searching a way to extract quicker the last line of my .gz file ... any idea anyone ? Note 1: For explain context, we can say database is MySql community, backup tool is mysqldump, generated dumpfile is a full text file. OS is CentOs. Backup script is Bash shell script. Note 2: I'm aware about Percona xtraBackup but in my case I want to use mysqldump f...

Appending with 2> and with >>

Appending with 2> and with >> Why do some scripts use 2> instead of >> ? Is the 2 just a multiplier of the > 's ? 2> >> > Read the Bash manual page – Some programmer dude Jun 29 at 10:45 3 Answers 3 1>> and 2>> are redirections for specific file-descriptors, in this case the standard output (file descriptor 1) and standard error (file descriptor 2). 2> Will output the error in the script to a file. ">>" Will append the output of a command to an existing file. If file doesn`t exists then it will create the file add the output to the file. See this link => https://unix.stackexchange.com/questions/183125/what-does-1-and-2-mean-in-a-bash-script For 2> means you are re-directing ...

Can't get result from grep in bash loop

Can't get result from grep in bash loop I'm trying to get info from log files using grep + tail -1: #!/bin/bash # declare an array called array and define 3 vales array=( 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 ) array2=( 00 30 ) for i in "${array[@]}" do for j in "${array2[@]}" do output=$(grep filtered /home/pavel/hasoffers_api/logs/tabatoo2_20180627$i$j* | tail -1) echo /home/pavel/hasoffers_api/logs/tabatoo2_20180627$i$j* echo "$output" done done this outputs just empty string, but I definitely know that phrase "filtered" is in the logs. What can be the problem? I tried several variations of the same script but it just returns empty string. Thanks! I think the script looks ok. The only explanation I see is that the string "filtered" is not in the logs or there's no files named ".../t...

Executing all files inside a folder in Python

Executing all files inside a folder in Python I have 20 Python files which is stored inside a directory in ubuntu 14.04 like 1.py, 2.py, 3.py , 4.py soon i have execute these files by "python 1.py", "python 2.py" soon for 20 times. is their a way to execute all python files inside a folder by single command ? 4 Answers 4 find . -maxdepth 1 -name "*.py" -exec python3 {} ; This will eventually recurse in subdirectories, which might not be what the OP wants. – bruno desthuilliers Jun 29 at 11:23 Added maxdepth 1 – RedEyed Jun 29 at 11:28 maxdepth 1 use p...

Whats the difference between virsh destroy and virsh undefine

Whats the difference between virsh destroy and virsh undefine I am new to servers and vms wanted to know the difference between virsh destroy and virsh undefine why did you tag python to this? have you checked the manual pages for the comand? I found this on the net: docs.oracle.com/cd/E19053-01/ldoms.mgr10/820-3838-10/… – dopstar Jun 29 at 9:36 Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See What topics can I ask about here in the Help Center. Perhaps Super User or Unix & Linux Stack Exchange would be a better place to ask. – jww Jun 29 at 10:19 2...

Print file count owned by a given user

Print file count owned by a given user How to print the number of files owned by every user in a given directory? So far I am printing user name and disk size. However I want to report out the output of " find $dirname -user <user_name>| wc -l " and print that as a third field in the below printf find $dirname -user <user_name>| wc -l set dirname = "a/b/c" find $dirname -printf "%u %sn" 2 Answers 2 I have a feeling you want to do something like this : find $dirname -printf "%u %sn" | awk '{s[$1]+=$2;c[$1]++}END{for(u in s) print u,s[u],c[u]} This will print a list of users with total accumulated file-size and the total amount of files. Exactly what I was trying to get at! Did a lot of circus and foreach loops with find <dir_name> -user <user_name | wc -l followed by saving the contents into an array. Ev...

Shell command to list file names where the matching is found

Shell command to list file names where the matching is found I am trying to search through a list of binary files to find some keywords on Mac. The following works to list out all the matches, but it doesn't show me the list of files where it is being found: find . -type f -exec strings {} ;|grep "Bv9qtsZRgspQliITY4" Is there any trick to do this? Do you still want to print the matches, or just the files’ names/paths? – Biffen Jun 29 at 10:07 5 Answers 5 Using -exec with a wee ‘script’: -exec find . -type f -exec sh -c 'strings "$1" | grep -q "Bv9qtsZRgspQliITY4"' -- {} ; -print The above will print the paths of all the matching files. If you also want to print the matches you can use: find . -typ...