I have a table as below:  FileHash              FilePath 1                     A.txt 3                     e.txt 3                     f.txt 3                     g.txt 3                     h.txt 2                     B.txt 2                     c.txt   In T-SQL, How to concatenate the first 3 FilePath of each FileHash as follows:  FileHash              FilePath 1                     A.txt 2                     B.txt, C.txt 3                     e.txt, f.txt, g.txt
456
I'm trying to migrate a MySQL-based app over to Microsoft SQL Server 2005 (not by choice, but that's life).  In the original app, we used almost entirely ANSI-SQL compliant statements, with one significant exception -- we used MySQL's group_concat function fairly frequently.  group_concat, by the way, does this: given a table of, say, employee names and projects...  SELECT empName, projID FROM project_members;   returns:  ANDY   |  A100 ANDY   |  B391 ANDY   |  X010 TOM    |  A100 TOM    |  A510   ... and here's what you get with group_concat:  SELECT      empName, group_concat(projID SEPARATOR ' / ')  FROM      project_members  GROUP BY      empName;   returns:  ANDY   |  A100 / B391 / X010 TOM    |  A100 / A510   So what I'd like to know is: Is it possible to write, say, a user-defined function in SQL Server which emulates the functionality of group_concat?   I have almost no experience using UDFs, stored procedures, or anything like that, just straight-up SQL, so please err on the side of too much explanation :)
31301
I have some files and each files have distinct name but all of them have the same "-statement" at the end like this:  flower-statement.mp3 leave-statement.mp3  ball-statement.mp3 goal-statement.mp3   So I want to remove this: -statement  Is that possible?
112069
I have multiple files with the same header and different vectors below that. I need to concatenate all of them but I want only the header of first file to be concatenated and I don't want other headers to be concatenated since they are all same.   for example: file1.txt  &lt;header&gt;INFO=&lt;ID=DP,Number=1,Type=Integer&gt; &lt;header&gt;INFO=&lt;ID=DP4,Number=4,Type=Integer&gt; A B  C   file2.txt  &lt;header&gt;INFO=&lt;ID=DP,Number=1,Type=Integer&gt; &lt;header&gt;INFO=&lt;ID=DP4,Number=4,Type=Integer&gt; D E  F   I need the output to be   &lt;header&gt;INFO=&lt;ID=DP,Number=1,Type=Integer&gt; &lt;header&gt;INFO=&lt;ID=DP4,Number=4,Type=Integer&gt; A B C D E  F   I could write a script in R but I need it in shell?
24577
For example, I want the first entry in Column B (B1) to show A5, then B2 shows A10, then B3 shows A15.  How would I go about doing this?
35201
I have files in the following format: x1 x2 ... x10 x11 ... x101 ...  I want to rename these files, so they all have the same name length: x001 x002 ... x010 ...  I can do this with files, that don't have the non-numeric prefix (just using sort -n followed by a while read x;), but sort doesn't recognize the numeric value, when it's not on the beginning of the file-name.
120659
Say I have the following query:  SELECT *  FROM AppDetails, AppTags  WHERE AppDetails.AppID = '1'    AND AppDetails.AppID = AppTags.AppID   Which gives the following results:  AppID    AppName        AppType    Tag 1        Application1   Utility    Test1 1        Application1   Utility    Test2 1        Application1   Utility    Test3   How can I modify the query to return something like this:  AppID    AppName        AppType    Tags 1        Application1   Utility    Test1,Test2,Test3
36486
if I have a csv file in the following format:  column1,column2,column3,column4,column5,column6,column7,column8   and I want awk to only print columns 2 till 7 I would use:  awk -F',' '{print $2 "," $3 "," $4 "," $5 "," $6 "," $7}' file.csv   and get:  column2,column3,column4,column5,column6,column7   is there a way to concatenate the columns 2-7 to simplify the command. As I'm thinking of a file with quite a bit more columns, my awk command would get horribly long.
50893
How do I truncate column "test10" to 5 characters from Unix command line?  From this  test1,test2,test3,test4,test10,test11,test12,test17 rh,mbn,ccc,khj,ee3 eeeeeEeee ee$eeee e.eeeee2eeeee5eeeeeeee,a2,3,u hyt,bb,mb,khj,R ee3ee eeEeee ee$eeee e.eeeee2eeeee5eeeeeeee,a,5,r mbn,htr,ccc,fdf,F1ee eeeeEeee ee$eeee e.eeeee2eeeee5eeeeeeee,a,e,r   To this  test1,test2,test3,test4,test10,test11,test12,test17 rh,mbn,ccc,khj,ee3 e,a2,3,u hyt,bb,mb,khj,R ee3,a,5,r mbn,htr,ccc,fdf,F1ee ,a,e,r
106822
Given a file with two columns:  Id  ht 510 69 510 67 510 65 510 62 510 59 601 29 601 26 601 21 601 20   I need a way to coalesce all rows with the same ID into one that has an average height. In this case, (69 + 67 + 65 + 62 + 59) / 5 = 64 and (29 + 26 + 21 + 20) / 4 = 24, so the output should be:  Id  Avg.ht  510 64  601 24   How can I do that using sed/awk/perl?
85314
I have a database which contains 5 tables. Each table contains 24 rows and each row contains 4 columns.  I want to display these records in Excel sheet. The heading of each table is the name of the table, but I am unable to merge the columns for heading.  Please help me.
44135
I have a directory filled with files with names like logXX where XX is a two-character, zero-padded, uppercase hex number such as:  log00 log01 log02 ... log0A log0B log0C ... log4E log4F log50 ...   Generally there will be fewer than say 20 or 30 files total.  The date and time on my particular system is not something that can be relied up on (an embedded system with no reliable NTP or GPS time sources).  However the filenames will reliably increment as shown above.  I wish to grep through all the files for the single most recent log entry of a certain type, I was hoping to cat the files together such as...  cat /tmp/logs/log* | grep 'WARNING 07 -' | tail -n1   However it occurred to me that different versions of bash or sh or zsh etc. might have different ideas about how the * is expanded.  The man bash page doesn't say whether or not the expansion of * would be a definitely ascending alphabetical list of matching filenames.  It does seem to be ascending every time I've tried it on all the systems I have available to me -- but is it DEFINED behaviour or just implementation specific?  In other words can I absolutely rely on cat /tmp/logs/log* to concatenate all my log files together in alphabetical order?
78992
I have several files that I ftp each hour.  The receiving system needs to have some sort of identifier that they came from the same batch, so I would like to append a timestamp to the filename.  That alone is fairly easy, but since I want each file to have the same timestamp (so it can serve as the batch identifier), I cannot figure out how to do this.  So, I have:  file1.txt file2.txt file3.txt   And I want to have:  file1_20141110184303.txt file2_20141110184303.txt file3_20141110184303.txt   Any use of the date +%Y%m%d%H%M%S after the first use will obviously result in a different values in seconds, so I would like to have the first timestamp appended to the remaining files.
91941
$ cat data.txt  aaaaaa aaaaaa cccccc aaaaaa aaaaaa bbbbbb $ cat data.txt | uniq aaaaaa cccccc aaaaaa bbbbbb $ cat data.txt | sort | uniq aaaaaa bbbbbb cccccc $   The result that I need is to display all the lines from the original file removing all the duplicates (not just the consecutive ones), while maintaining the original order of statements in the file.  Here, in this example, the result that I actually was looking for was  aaaaaa cccccc bbbbbb   How can I perform this generalized uniq operation in general?
37579
This is a link I have in a column of a table:  http://earthexplorer.usgs.gov/browse/etm/1/11/2000/LE70010112000130KIS00.jpg   There are like 1000's of rows like this.    Is it possible to extract the FileName like LE70010112000130KIS00 (without the path and filename extension) and put it in another column?    I am new to SQL Server.
21687
I have these lines in the fstab   # binds /media/DataNtfs/Music           /home/can/Music                  none    rw,bind  /media/DataNtfs/Pictures        /home/can/Pictures               none    rw,bind  /media/DataNtfs/Downloads       /home/can/Downloads              none    rw,bind  /media/DataNtfs/Documents       /home/can/Documents              none    rw,bind  /media/DataNtfs/Backups         /home/can/Backups                none    rw,bind  /media/DataNtfs/Notes           /home/can/Notes                  none    rw,bind  /media/DataNtfs/Other           /home/can/Other                  none    rw,bind  /media/DataNtfs/Packages        /home/can/Packages               none    rw,bind  /media/DataNtfs/Photos          /home/can/Photos                 none    rw,bind  /media/DataNtfs/Videos          /home/can/Videos                 none    rw,bind  /media/DataNtfs/WorkSpace       /home/can/WorkSpace              none    rw,bind
21952
I want to combine two ffmpeg commands to a single command. I am using ready made ffmpeg binary in my Android application. I want to concat .ts files and overlay an image.  I am using following commands:   To concat .ts files:  String[] ffmpegcommand = {"ffmpeg", "-i","concat:"+input_file_path+"|"+input_file_path1, "-c", "copy", "-bsf:a", "aac_adtstoasc", output_file_path};  Apply image overlay effect:  String[] ffmpegcommand = {"ffmpeg","-y" ,"-i", input_file_path,"-strict","experimental", "-vf","movie="+AppStaticData.BASE_FOLDER_PATH + File.separator + "watermarklogo.png"+" [watermark]; [in][watermark] overlay=main_w-overlay_w-10:10 [out]", AppStaticData.BASE_FOLDER_PATH+"/" + output_file_path};
38248
I have three tables and i need an out put which has data from two tables, i would like to create the same using macro.  Table A  A B C D   Table B  Apple Orange Pears   Table C  Americas Asia Europe   The Output i need is  A Apple Americas A Apple Asia A Apple Europe A Orange Americas A Orange Asia A Orange Europe   So i guess for each letter from Table A, there would be 12 additional rows created. The above is the sample data and I have around 5000 rows in Table A.