snipt

Ctrl+h for KB shortcuts

Markdown

Transform file list and more sed tricks

This command will print the filename and save them filtering only the part before the underscore.

ls| sed 's/_/ /g' | awk 'BEGIN {} $1 ~ /[0-9]/ {print $1}' > ../subcodes.txt
https://snipt.net/embed/d1cc07b2865af9f79b029efd2bb24313/
/raw/d1cc07b2865af9f79b029efd2bb24313/
d1cc07b2865af9f79b029efd2bb24313
markdown
Markdown
3
2019-08-19T19:01:15
True
False
False
Mar 25, 2014 at 01:28 PM
/api/public/snipt/124715/
transform-file-list-and-more-sed-tricks
<p>This command will print the filename and save them filtering only the part before the underscore.</p> <pre><code>ls| sed 's/_/ /g' | awk 'BEGIN {} $1 ~ /[0-9]/ {print $1}' &gt; ../subcodes.txt </code></pre>
awk, sed

Markdown

Select all except selected columns

SET @sql = CONCAT('SELECT ', (SELECT REPLACE(GROUP_CONCAT(COLUMN_NAME), '<columns_to_omit>,', '') FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '<table>' AND TABLE_SCHEMA = '<database>'), ' FROM <table>');

PREPARE stmt1 FROM @sql;
EXECUTE stmt1;
https://snipt.net/embed/0cfa6b34148041c877dd0e9a939829dc/
/raw/0cfa6b34148041c877dd0e9a939829dc/
0cfa6b34148041c877dd0e9a939829dc
markdown
Markdown
4
2019-08-21T16:20:41
True
False
False
Oct 23, 2013 at 12:16 PM
/api/public/snipt/89632/
select-all-except-selected-columns
<pre><code>SET @sql = CONCAT('SELECT ', (SELECT REPLACE(GROUP_CONCAT(COLUMN_NAME), '&lt;columns_to_omit&gt;,', '') FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '&lt;table&gt;' AND TABLE_SCHEMA = '&lt;database&gt;'), ' FROM &lt;table&gt;'); PREPARE stmt1 FROM @sql; EXECUTE stmt1; </code></pre>
mysql, sql

Text only

Change filenames using sed

for f in *.jpg; do mv $f `echo $f | sed s/IMG/VACATION/`; done
https://snipt.net/embed/b63e55d147a67189bd8ce929d0a80521/
/raw/b63e55d147a67189bd8ce929d0a80521/
b63e55d147a67189bd8ce929d0a80521
text
Text only
1
2019-08-23T20:12:32
True
False
False
Aug 15, 2013 at 05:01 PM
/api/public/snipt/74511/
change-filenames-using-sed
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>for f in *.jpg; do mv $f `echo $f | sed s/IMG/VACATION/`; done </span></pre></div> </td></tr></table>
sed