User Tools

Site Tools


linux:bashshell

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
linux:bashshell [2016/07/08 07:14] – [update array to file] adminlinux:bashshell [2022/10/29 16:15] (current) – external edit 127.0.0.1
Line 315: Line 315:
 </code> </code>
 ==== Find files that contain the text ==== ==== Find files that contain the text ====
-<code bash>+  * Simple<code bash>
 grep -rnw . -e "Begin Facebook Code" grep -rnw . -e "Begin Facebook Code"
 +</code>
 +  * Custom find with regular expression<code bash>
 +grep -rnw . -e 'mongo.*'
 +</code>
 +==== Find files that file name length > 29 ====
 +<code bash>
 +for i in `ls -1`;do sub_i=(`echo $i|cut -d'-' -f 1`);lensub_i=${#sub_i}; if [ $lensub_i -ge 29 ]; then echo $sub_i;echo $i; fi  done
 </code> </code>
 ==== Manipulating String ==== ==== Manipulating String ====
Line 338: Line 345:
 update array to files: update array to files:
 <code bash> <code bash>
-index=0;for i in `cat configs.txt | awk '{print $3}'`; do let "index = $index + 1";echo $i > c$index; done+index=0;for i in `cat configs.txt | awk '{print $3}'`; do let "index = $index + 1";echo $i > c$index.txt; done
 </code> </code>
linux/bashshell.1467962042.txt.gz · Last modified: 2022/10/29 16:15 (external edit)