currently I have faced a problem in changing a string in a file which have / character . I want to replace 1/0 with hetero in a file. can you tell me which command to use ?
123367
I want to replace 0/1 with hetero but whenever I am trying to use the known commands it is showing syntax error because the / is aleady part of the command .. Can anyone suggest a command to solve this issue??
28017
I'm using this command to rename files:  for fname in *; do     mv "$fname" $(echo "$fname" | sha1sum | cut -f1 -d' ') done   But it only renames in the current directory. Let's say I have many directories, and each directory contains some other directories, and last directory tree contains files. I want to rename them with random characters.  I think find . -type f should work, and have tried it, but still did not get any working command.
96290
How can I replace spaces with new lines on an input like:  /path/to/file /path/to/file2 /path/to/file3 /path/to/file4 /path/to/file5 etc...  To obtain the following:  /path/to/file /path/to/file2 /path/to/file3 /path/to/file4 /path/to/file5   Note  I'm posting this question to help other users, it was not easy to find a useful answer on UNIX SE until I started to type this question. After that I found the following:  Related question
102347
I am curious as to whether there is an equivalent to the Alt-. command on Mac. On my computer it inserts the following character: ≥, instead of showing the .
83409
I want to write a sed (or awk) command to replace a string from one file with the entire contents of another file. Note that second file from which I want to get the content has more than one line. I tried this:  sed -e "s/PLACEHOLDER/$(sed 's:/:\\/:g' TestOutput.txt)/" SQLInput.txt   but got an error saying sed: -e expression #1, char 22: unterminated 's' command
51777
'4800483343' is a directory, and 'file1' &amp; 'file2' are two files in it.  Why is the following happening?  $ ls 4800483343 file1 file2  $ md5sum 4800483343/* 36468e77d55ee160477dc9772a99be4b  4800483343/file1 29b098f7d374d080eb006140fb01bbfe  4800483343/file2  $ mv 4800483343 4800[48]3343  $ md5sum 4800[48]3343/* md5sum: 4800[48]3343/*: No such file or directory  $ md5sum '4800[48]3343'/* 36468e77d55ee160477dc9772a99be4b  4800[48]3343/file1 29b098f7d374d080eb006140fb01bbfe  4800[48]3343/file2   What other characters cause this?
94139
I found an answer for  which works fine for renaming filenames as follows :  1.jpg &gt; 00001.jpg 2.jpg &gt; 00002.jpg . . . 9.jpg &gt; 00009.jpg   That uses the following command:  rename 's/\d+/sprintf("%05d", $&amp;)/e' *.jpg   But my filenames aren't numeric. They are an alphanumeric sequence, like: a.jpg, b.jpg, c.jpg...... m.jpg.  In a similar way to the original question, I want to rename these so they display in the correct sequence. How do I do this?
106661
I have an input file, say, file1, which appears as follows:  WRITE=2 START=1 SMEAR=0 MIN=6 MAX=100   My problem is to search for the string SMEAR and if the string exists replace the entire line with SMEAR=-5. However, if the SMEAR does not exist, then I need to insert a new line SMEAR=-5. Ultimately the line SMEAR=-5 should appear only once. I can replace the string using sed:   sed -i '/SMEAR/c\SMEAR=-5' file1   Or I can insert the string as a new line    sed -i '10i SMEAR=-5' file1   But how can I combine them based on the existence of the string in the file?  EDIT: Also it would be helpful if I can pass the value of SMEAR as a variable.
77611
Good day. Using only Linux OS tools, how would you convert the following text from this: cat latest.csv apsga,alp1acscf0001vm001oam001p1n004v001,192.7.129.7,UVP apsga,alp1acscf0001vm001oam001p1n004v002,192.7.129.8,UVP apsga,alp1acscf0001vm002oam001p1n004v001,192.7.129.9,UVP apsga,alp1acscf0001vm003oam001p1n004v001,192.7.129.10,UVP apsga,alp1acscf0001vm004cif001p1n004v001,192.7.129.11,UVP apsga,alp1acscf0001vm004cif001p1n004v002,192.7.129.12,UVP apsga,alp1acscf0001vm005cif001p1n004v001,192.7.129.13,UVP  I managed to get the following result: cat latest.csv`|awk -F',' '{print $2, $3}'|awk '{ $1 = substr($1,1,21); print $1&quot;,&quot;$2}' alp1acscf0001vm001oam,192.7.129.7 alp1acscf0001vm001oam,192.7.129.8 alp1acscf0001vm002oam,192.7.129.9 alp1acscf0001vm003oam,192.7.129.10 alp1acscf0001vm004cif,192.7.129.11 alp1acscf0001vm004cif,192.7.129.12 alp1acscf0001vm005cif,192.7.129.13  I would like the end result to look like this: ALP1A/alp1acscf0001v,UUID,192.7.129.7,SSH2,alp1acscf0001vm001oam ALP1A/alp1acscf0001v,UUID,192.7.129.8,SSH2,alp1acscf0001vm001oam ALP1A/alp1acscf0001v,UUID,192.7.129.9,SSH2,alp1acscf0001vm002oam ALP1A/alp1acscf0001v,UUID,192.7.129.10,SSH2,alp1acscf0001vm003oam ALP1A/alp1acscf0001v,UUID,192.7.129.11,SSH2,alp1acscf0001vm004cif ALP1A/alp1acscf0001v,UUID,192.7.129.12,SSH2,alp1acscf0001vm004cif ALP1A/alp1acscf0001v,UUID,192.7.129.13,SSH2,alp1acscf0001vm005cif  Thanks in advance, Bjoern
29774
I found the following command to repeat a character in Linux:  printf 'H%.0s' {1..5000} &gt; H.txt   I want, for example, H to repeat 5000 times. What does %.0s mean here?
18177
I have a text file containing this:  0 0 -1 0 1 0 0 0 0 -1 0 0 1.5 0.0 1.0 1   and I want to replace the 1.0 to 2.0 so that it becomes:  0 0 -1 0 1 0 0 0 0 -1 0 0 1.5 0.0 2.0 1   so I use this command:  sed -i 's/'1.0'/'2.0'/g' /home/user1/file1.txt   or this:  sed -i 's/1.0/2.0/g' /home/user1/file1.txt   but this is the result that appears and I don't know how to fix this:  0 0 -2.0 2.0 0 0 0 -2.0 0 1.5 0.0 2.0 1
22815
I have a folder in which I have around 4k files. Some of these files start with a a ? or ! character. I need to delete them but can't find an expression that would do so:   rm -f ./?*   just deletes everything. I can possibly use grep on ls and pipe it through xargs and move files to another folder but I was hoping there was a proper way of doing this. Need help on both the ? and ! files.
25014
How can I recursively replace a string in all folders and files' name with a different string? I am running Red Hat 6 and I can find them with:  find . -name \*string\*   I've managed to do it for strings within files:  find . -type f -exec sed -i 's/string1/string2/g' {} +   but how could I replace in a similar way all file names?
15365
In Perl, what is a good way to perform a replacement on a string using a regular expression and store the value in a different variable, without changing the original?  I usually just copy the string to a new variable then bind it to the s/// regex that does the replacement on the new string, but I was wondering if there is a better way to do this?  $newstring = $oldstring; $newstring =~ s/foo/bar/g;
87368
I did tried sed and awk, but its not working as the character involves / which is already there in command as delimiter. Please let me know how can I achieve this. Below is a sample Example. We want to remove the commented sections, i.e /*.....*/ /*This is to print the output data*/ proc print data=sashelp.cars; run; /*Creating dataset*/ data abc; set xyz; run;
1654
How to define a command which replaces every instance of a certain character in its argument with another certain character?  For example, I'd like to define the command \myreplace{1-2-abc-345} which gives me the output 1.2.abc.345 by replacing every - with ..
25058
What is the fastest, easiest tool or method to convert text files between character sets?  Specifically, I need to convert from UTF-8 to ISO-8859-15 and vice versa.  Everything goes: one-liners in your favorite scripting language, command-line tools or other utilities for OS, web sites, etc.  Best solutions so far:  On Linux/UNIX/OS X/cygwin:   Gnu  suggested by  is best used as a filter. It seems to be universally available. Example:  $ iconv -f UTF-8 -t ISO-8859-15 in.txt &gt; out.txt   As pointed out by , there is an . Gnu  () suggested by  will convert one or several files in-place. Example:  $ recode UTF8..ISO-8859-15 in.txt   This one uses shorter aliases:  $ recode utf8..l9 in.txt   Recode also supports surfaces which can be used to convert between different line ending types and encodings:  Convert newlines from LF (Unix) to CR-LF (DOS):  $ recode ../CR-LF in.txt   Base64 encode file:  $ recode ../Base64 in.txt   You can also combine them.  Convert a Base64 encoded UTF8 file with Unix line endings to Base64 encoded Latin 1 file with Dos line endings:  $ recode utf8/Base64..l1/CR-LF/Base64 file.txt    On Windows with  ():    PS C:\&gt; gc -en utf8 in.txt | Out-File -en ascii out.txt  (No ISO-8859-15 support though; it says that supported charsets are unicode, utf7, utf8, utf32, ascii, bigendianunicode, default, and oem.)   Edit  Do you mean iso-8859-1 support? Using "String" does this e.g. for vice versa  gc -en string in.txt | Out-File -en utf8 out.txt   Note: The possible enumeration values are "Unknown, String, Unicode, Byte, BigEndianUnicode, UTF8, UTF7, Ascii".   CsCvt -  is another great command line based conversion tool for Windows.