bash

Bash SH Script - Rename File with specific extension + Move to specific location

眉间皱痕 提交于 2021-02-18 19:43:39
问题 SEE VISUAL EXPLANATION and EDIT I'm trying to create a bash script to do a rename+move. This is the example situation: |DOCTEMP - NameOfTheFolder---------|NameOfADocument.docx FOLDER---| |DOCFINAL - OtherNameOfTheFolder---|OtherNameOfADocument.pdf | |etc. What I want to do is a script that: Part I Only if the file has docx, pdf, ppt then rename it as its folder but without DOCTEMP - / DOCFINAL - . NameOfADocument.docx => NameOfTheFolder.docx OtherNameOfADocument.pdf => OtherNameOfTheFolder

In BASH, how do I use defaults write on a plist for a existing element in an array?

假如想象 提交于 2021-02-18 19:14:10
问题 I want to change the value of DEFAULT_VALUE_PLACEHOLDER in the following plist using the command line tool defaults <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>PreferenceSpecifiers</key> <array> <dict> <key>DefaultValue</key> <string>DEFAULT_VALUE_PLACEHOLDER</string> <key>Type</key> <string>PSTitleValueSpecifier</string> <key>Title</key> <string>Version</string>

Python3 Run Alias Bash Commands

你离开我真会死。 提交于 2021-02-18 18:54:37
问题 I have the following code that works great to run the ls command. I have a bash alias that I use alias ll='ls -alFGh' is it possible to get python to run the bash command without python loading my bash_alias file, parsing, and then actually running the full command? import subprocess command = "ls" # the shell command process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=None, shell=True) #Launch the shell command: output = process.communicate() print (output[0]) Trying with

How to translate the wslpath /home/user/ to windows path

二次信任 提交于 2021-02-18 18:40:14
问题 I use Linux subsystem of windows 10(windows 10 version 1803) I can use command line: user@laptop:~$ wslpath -w /c/ C:\ But when I try to use user@laptop:~$ wslpath -w ~ wslpath: /home/user: Result not representable Even I use: user@laptop:~$ wslpath -w /home/user wslpath: /home/user: Result not representable why? how to translate the /home/user to windows path? my home folder path in windows is C:\Users\winuser\AppData\Local\lxss\home I expect some command line can give me return that string.

How to compile bash?

左心房为你撑大大i 提交于 2021-02-18 16:58:09
问题 How to compile bash? I did small modifications to the code I got from http://ftp.gnu.org/gnu/bash/bash-4.2.tar.gz. I want to see those changes. Can anyone please point to me simple steps to compile bash? 回答1: You can first run cd bash-4.2 ./configure --prefix=/usr \ --bindir=/bin \ --htmldir=/usr/share/doc/bash-4.2 \ --without-bash-malloc \ --with-installed-readline make make install Also refer http://www.linuxfromscratch.org/lfs/view/development/chapter06/bash.html for more information 回答2:

为什么黑客从不用鼠标,一直在敲键盘?看完长见识了

落花浮王杯 提交于 2021-02-18 15:21:17
点击下方“ 民工哥技术之路 ”,选择“设为星标” 回复“ 1024 ”获取独家整理的学习资料! 在各种好莱坞大片里头,但凡需要“技术小子”表现一下如何用几分钟时间黑掉一个庞大IT系统的时候,里面的电脑都是这样的: 文字处理软件从来不显示光标。 所有的屏幕都显示1英尺高的字符。 高技术的计算机都有简单易用的图形界面。 即便是没有图形界面,计算机也能正确理解自然语言并执行。 只需要敲入“读出秘密文件”(“Access The Secret Files”),计算机就会给出任何你想要的信息。 仅仅通过敲入“上载病毒”(“Upload Virus”),就能够攻击一台计算机。 黑客总是能够在仅仅猜测密码一两次的情况下,就进入保密的计算机。 磁盘可以用在任何有软盘驱动器的计算机上,并且所有的软件可以工作在任何平台上。 笔记本计算机总有实时电视电话能力,它们的性能就是比超级CRAY计算机也不差。 有一个细节是,很多时候里面出现特别专业的操作电脑的画面时,基本没有鼠标的影子!还记得《黑客帝国》里接线员坦克操作的电脑么?不仅是图形界面,而且是键盘操作——根本没有放鼠标或者轨迹球的地方——再就是显示器屏幕旁的几个旋钮扳来扳去。 当然电影就是电影,不过黑客鼠标用得少也是事实,据某黑客的专业解读: 1、懒得搞图形界面。 看起来简单的图形界面实现起来工作量非常大

GNU Parallel: split file into children

泪湿孤枕 提交于 2021-02-18 11:34:12
问题 Goal Use GNU Parallel to split a large .gz file into children. Since the server has 16 CPUs, create 16 children. Each child should contain, at most, N lines. Here, N = 104,214,420 lines. Children should be in .gz format. Input File name: file1.fastq.gz size: 39 GB line count: 1,667,430,708 (uncompressed) Hardware 36 GB Memory 16 CPUs HPCC environment (I'm not admin) Code Version 1 zcat "${input_file}" | parallel --pipe -N 104214420 --joblog split_log.txt --resume-failed "gzip > ${input_file}

GNU Parallel: split file into children

只愿长相守 提交于 2021-02-18 11:34:09
问题 Goal Use GNU Parallel to split a large .gz file into children. Since the server has 16 CPUs, create 16 children. Each child should contain, at most, N lines. Here, N = 104,214,420 lines. Children should be in .gz format. Input File name: file1.fastq.gz size: 39 GB line count: 1,667,430,708 (uncompressed) Hardware 36 GB Memory 16 CPUs HPCC environment (I'm not admin) Code Version 1 zcat "${input_file}" | parallel --pipe -N 104214420 --joblog split_log.txt --resume-failed "gzip > ${input_file}

Execute an array of string describing shell command

a 夏天 提交于 2021-02-18 11:08:41
问题 I'm struggling to execute a set of command lines stored as strings in an array. My code looks like this : arr=( "sudo apt-get update" "sudo apt-get install xxx" ) ... arr=( ${arr[@]} "ln -s /path1 /path2" ) etc... # Then I loop on the array of command for (( i = 0 ; i < ${#arr[@]} ; i++ )) do eval ${arr[$i]} done When it loops over the array, the array is larger than the number of command stored into it. As if the blank spaces in my strings split the array in more elements A typical ouput is

Running a binary without a top level script in SLURM

心不动则不痛 提交于 2021-02-18 11:08:22
问题 In SGE/PBS, I can submit binary executables to the cluster just like I would locally. For example: qsub -b y -cwd echo hello would submit a job named echo, which writes the word "hello" to its output file. How can I submit a similar job to SLURM. It expects the file to have a hash-bang interpreter on the first line. On SLURM I get $ sbatch echo hello sbatch: error: This does not look like a batch script. The first sbatch: error: line must start with #! followed by the path to an interpreter.