New answers tagged

0

gawk 4.1.0 onwards, an in-place editing option is available. So in one fell swoop awk -i inplace -v INPLACE_SUFFIX=.bak ' BEGINFILE{x=FILENAME; sub(/\..*/, "", x)}; /^>OT/{$0 =$0"_"x}; {print}' *.fasta will update files as needed in-place. -v INPLACE_SUFFIX=.bak causes original files to be backed up with a .bak suffix


3

Make sure you have a backup of your files before starting to change them all You can run something like the following: for i in *.fasta; do nr="${i%.fasta}"; sed -i 's/^>OTU\(.*\)$/>OTU\1_'$nr'/' "$i"; done if you have a version of sed that supports -i (in place editing). The nr="${i%.fasta}" part gets you the number from the filename. The \(.*\) ...


1

I know this is an old question but i have been searching all night for a similar solution. I found a few helpful tips but they did not do exactly what i needed, so I had to mix and match a few to get the correct outcome I was looking for to simply remove special characters and replace them with a (.) dot for f in *.txt; do mv "$f" `echo $f | sed ...


1

If all the files in question have the same prefix (i.e., the text before the number; c in this case), you can use gs …args… c?.pdf c??.pdf c?.pdf expands to c0.pdf c1.pdf … c9.pdf.  c??.pdf expands to c10.pdf c11.pdf … c20.pdf (and up to c99.pdf, as applicable).  While each command-line word containing pathname expansion character(s) is expanded to a ...


0

Note that {1..20} is not a wildcard/globbing operator. That's a special form of brace-expansion introduced by zsh and copied with limitations and variations by ksh93 and bash. foo_{0001..0030}.nc doesn't expand to the list of matching files, it expands to foo_0001.nc, foo_0002.nc, ... foo_0030.nc regardless of whether the files exist or not. bash has that ...


1

Brace expansion happens before variable expansion, so there's no way to use variables in it. You can use seq instead: seq -f foo_%03.0f.nc $ns $ne


0

Thanks for all the suggestions, I took pieces from everyone's suggestions and built this command. In my case this is exactly the command I required. for f in /mydirectory/*.zip; do n=$(echo ${f##*/} | cut -c1-30); unzip -d /mydirectory/$n $f; done It loops through all the zip files Echos each zip file (file name only, no extra info like size or ...


1

With sed you can get the first 30 characters: sed 's|\(.\{30\}\).*|\1|' and use that instead of cut in your for loop. The breakdown of that sed substitution is that what is matched between \( \) you substitute with \1. the {30} (escaped with \) counts 30 single characters (.).


-1

Nautilus used to have these options : View >> Arrange Items >>> 1 Manually 2 By Name 3 By Type 4 By Modification Date 5 By Emblems Suggest "By Name", then it should be alphabetical order.


-1

Try this alias and use it: alias l='ls -hLlF'


0

You can do it with find: find . -regextype posix-extended \ -type f ! -regex '.*/[0-9A-Z]{1,2}_[[:digit:]]{4}_[[:alnum:]_]+?\.dat' -delete Of course you can put it all on one line (removing the \ at the end of the first line). -regextype posix-egrep seems to work exactly as well as -regextype posix-extended. If your version of find doesn't ...


5

Using extended globs: shopt -s extglob printf '%s\n' !([[:digit:][:upper:]]?([[:digit:][:upper:]])_[[:digit:]][[:digit:]][[:digit:]][[:digit:]]_+([[:alnum:]]).dat) this will print all file/directory names that do not (!) match [[:digit:][:upper:]] followed by zero or one [[:digit:][:upper:]] followed by 4 [[:digit:]] in between _s and then one or more ...


3

There are many ways of doing this. You could use a scripting language that understands regular expressions. For example, in Perl: perl -le 'unlink(grep(!/[0-9A-Z]{1,2}_\d{4}_\w+?.dat/,@ARGV))' * That will look for all files (not subdirectories) in the current directory, collect those that don't match the regex and delete them. You could also do a ...


-2

If your phone is rooted (which based on your statement, "I tried to root it by typing su" I'm gonna guess it isn't but I'm not sure), you can just install BusyBox and a terminal emulator to have more of the linux commands you're probably expecting or used to. This will really only allow you to copy to a connected USB or SD card and is basically done in an ...


0

You can try syntax variations until your keyboard wears out. find is not found by the shell you've started, and that has to be fixed first. I don't recall having seen find in ADB, so I would first make sure you actually do have that command and decide on a different strategy if you don't. You could e.g. try to grep the output of ls -R


0

I found out that the .$EXTEND directory is created on an Oracle ZFS storage system when SMB is enabled. SMB can be disabled for the pool but the .$EXTEND directory still cannot be removed.


3

dirname of file is missing in first part, try grep -w 'sucessfully completed.' "/var/log/folder/$(ls -1rt /var/log/folder | tail -n1)" do not try ... unles there is no dir in /var/log/folder/ grep -w 'sucessfully completed.' "$(ls -1rt /var/log/folder/* | tail -n1)"


2

To differentiate a variable from a string bash uses $. When you do : rm -R .$EXTEND variable $EXTEND is expanded and the result is substituted. Inorder to remove .$EXTEND file you need to tell bash to interpret $ without its special meaning. You can do it two ways : rm -R .\$EXTEND #\ strips the special meaning of $ or rm -R '.$EXTEND' # Use single ...


4

You can either escape the $ sign: rm -r .\$EXTEND or use single quotes: rm -r '.$EXTEND'



Top 50 recent answers are included